Sha256: ed1059de70993b01952ad921cd91c7ef05319a7d64655faf5e52880d02137fe3
Contents?: true
Size: 882 Bytes
Versions: 85
Compression:
Stored size: 882 Bytes
Contents
//Setup a server on port 9999 to accept incomming connections var io = require('socket.io')(); var rl = require('readline'); var r = rl.createInterface({ input: process.stdin, output: new require('stream').Writable(), terminal: false }); var stdin = process.stdin; _socket = null; //stdin.resume(); r.on("line", function(chunk) { var res = JSON.parse(chunk.toString()); type = res.type; msg = res.msg; _socket.emit(type, msg); }); io.on('connection', function(socket) { _socket = socket; console.log("CLIENT CONNECTED"); socket.on("if_dispatch", function(data) { console.log("if_dispatch"); console.log(JSON.stringify(data)); }); socket.on("int_dispatch", function(data) { console.log("int_dispatch"); console.log(JSON.stringify(data)); }); }); io.listen(9999); function call() { console.log("STARTED"); } setTimeout(call, 1000);
Version data entries
85 entries across 85 versions & 1 rubygems