-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorker.ts
More file actions
65 lines (44 loc) · 1.3 KB
/
Worker.ts
File metadata and controls
65 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {Application} from "./application";
import {StreamTest} from "./apps/StreamTest";
import {ledtisch, writeToSocket} from "./index";
const WebSocket = require('ws');
const FPS = 15;
export async function startApp(appuuid: string, ws:any, session: string) {
// const ws = expressWs.get(0);
// const ws = expressWs.get(0);
try {
let startedApp: Application = null;
console.log("Client start streaming")
switch (appuuid) {
case "0186cdd1-92f3-11eb-ad01-0242ac110002":
startedApp = new StreamTest();
break;
default:
ws.close();
break;
}
startedApp.onCreate();
var counter1 = 0;
var counter2 = 0;
while (true) {
await new Promise(r => setTimeout(r, 1));
counter1++;
counter2++;
if(counter1==7) {
counter1 =0;
startedApp.onRun()
}
if(counter2==90) {
counter2 = 0;
startedApp.onDraw();
ledtisch.show(ws);
}
if (ws.readyState !== WebSocket.OPEN) {
console.log("Client left")
return;
}
}
}catch (e) {
console.log(e)
}
}