{"size": 945, "ext": "js", "max_stars_repo_path": "queue.js", "max_stars_repo_name": "nugget/roon-community-dj", "max_stars_repo_stars_event_min_datetime": "2020-04-19T02:48:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T01:43:17.000Z", "max_issues_repo_path": "queue.js", "max_issues_repo_name": "nugget/roon-community-dj", "max_issues_repo_issues_event_min_datetime": "2020-04-19T03:19:19.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T10:58:38.000Z", "max_forks_repo_path": "queue.js", "max_forks_repo_name": "nugget/roon-community-dj", "max_forks_repo_forks_event_min_datetime": "2020-04-22T03:19:47.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-22T03:19:47.000Z"}
{"max_stars_count": 3, "max_issues_count": 20, "max_forks_count": 1, "avg_line_length": 20.1063829787, "max_line_length": 48, "alphanum_fraction": 0.6052910053}
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);
    }
});
