-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
queue.js
46 lines (36 loc) · 945 Bytes
/
queue.js
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
var WebSocket = require("@oznu/ws-connect");
var config = require("./config.json");
var debugFlag = false;
var serverid = "devserver";
var url = config.settings.server;
console.log("Connecting to %s", url);
var ws = new WebSocket(url);
var readline = require("readline");
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on("line", function (line) {
if (line == "") {
return;
}
try {
var track = JSON.parse(line);
} catch (e) {
console.log("INVALID", e);
return;
}
track.serverid = serverid;
track.channel = config.settings.channel;
track.nickname = "fakeuser";
ws.send(JSON.stringify(track));
});
ws.on("open", function open() {
console.log("Connection open");
});
ws.on("message", function incoming(data) {
if (debugFlag || data.action == "PLAYING") {
console.log(data);
}
});