-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
60 lines (39 loc) · 1.2 KB
/
index.ts
File metadata and controls
60 lines (39 loc) · 1.2 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
import { startApp } from "./Worker";
import {VirtualLEDWall} from "./virtualdevices/VirtualLEDWall";
const express = require('express')
const app = express()
const port = 3000
var expressWs = require('express-ws')(app);
const axios = require('axios');
var connections = [];
import {Neopixel} from "./virtualdevices/Neopixel";
export var ledtisch;
const backend = "https://api.arnold-tim.de";
function init() {
ledtisch = new VirtualLEDWall(10,15,1);
ledtisch.init(new Neopixel());
}
init();
app.get('/', (req, res) => {
res.send('LEDWall Stream Server V1.0')
})
app.ws('/startLiveApp', (ws,req)=> {
if(req.query.session&&req.query.appuuid) {
axios.get(backend+"/auth/validateSession"+"?session="+req.query.session).then((result) => {
if(result.data.success) {
startApp(req.query.appuuid,ws,req.query.session);
}else{
ws.send("Invalid Session")
ws.close();
}
});
}else{
ws.close();
}
})
export function writeToSocket(socketid:number,message:string) {
connections[socketid].send(message);
}
app.listen(port, () => {
console.log(`Stream App listening at http://localhost:${port}`)
})