Last active
December 16, 2015 03:59
-
-
Save LeoOnTheEarth/5374101 to your computer and use it in GitHub Desktop.
A simple log.io client implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="socket.io.min.js"></script> | |
<script> | |
var socket = io.connect('http://localhost:5000/'); | |
socket.on('connect', function() { | |
socket.on('add_stream', function (data) { | |
console.dir({add_stream_data:data}); | |
var length = data.pairs.length; | |
for (var i = 0; i < length; ++i) { | |
socket.emit('watch', data.name + ':' + data.pairs[i]); | |
} | |
}); | |
socket.on('new_log', function (data) { | |
console.dir({new_log_data:data}); | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var server = net.createServer(function(c) { //'connection' listener | |
console.log('server connected'); | |
c.on('end', function() { | |
console.log('server disconnected'); | |
}); | |
c.on('data', function (data) { | |
console.dir(data.toString()); | |
}); | |
}); | |
server.listen(10080, function() { //'listening' listener | |
console.log('server bound'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment