-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
63 lines (52 loc) · 1.22 KB
/
index.js
File metadata and controls
63 lines (52 loc) · 1.22 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
const express = require('express');
const app = express();
const { ArtNetController } = require('artnet-protocol/dist')
//const Config = require("./Config.json");
const { json } = require('body-parser');
const fs = require('fs')
function Sleep(milliseconds)
{
const date = Date.now();
let currentDate = null;
do
{
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
function setTerminalTitle(title)
{
process.stdout.write(
String.fromCharCode(27) + "]0;" + title + String.fromCharCode(7)
);
}
setTerminalTitle("Roblox DMX by Locos")
//Config
var Config
const path = "./Config.json"
if (fs.existsSync(path))
{
var Data = fs.readFileSync(path, 'utf8')
Config = JSON.parse(Data)
}
else
{
console.log("Config File not exits.")
Sleep(5000);
process.exit(1);;
}
// settings
app.set('port', Config.ServerPort);
// listening the Server
app.listen(app.get('port'), () => {
console.log('Server started on port', app.get('port'));
});
//DMX
const controller = new ArtNetController();
controller.bind(Config['Art-Net_IP']);
var DMX = []
controller.on('dmx', (dmx) => {
DMX[dmx.universe] = dmx.data
});
app.get('/', (req, res) => {
res.send(DMX)
});