bitmessage-js/tests/tcp-node.js

18 lines
488 B
JavaScript
Raw Normal View History

2015-02-06 09:47:40 +00:00
var TcpTransport = require("../lib/net/tcp");
2015-02-05 18:38:36 +00:00
function start() {
var server = new TcpTransport({port: 22333});
2015-02-09 21:56:55 +00:00
// In node 0.12/io 1.0 we can use {host: x, port: y} syntax so it'll
// be more compatible with the ws transport options.
2015-02-09 14:38:10 +00:00
server.listen(22333, "127.0.0.1");
server.on("connection", function(client) {
client.on("message", function(command, payload) {
if (command === "echo-req") {
client.send("echo-res", payload);
}
});
});
2015-02-05 18:38:36 +00:00
}
start();