-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest-node.js
36 lines (32 loc) · 932 Bytes
/
test-node.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
var assert = require("assert");
var th = require("telehash");
delete th.extensions.udp4;
delete th.extensions.tcp4;
delete th.extensions.http;
th.add(require("./"));
th.log({info: function(){}});
// th.log({debug: console.log});
var idB = {
keys: {"3a": "oh5mgzdlfbkvtim3dfbxdeozc6qot5yn4vazcaundvz77cjlfm6q"},
secrets: {"3a": "36al6qy6xzrky7ft64ldf2acj2tt2axpjsqakkdmhyr2v5c3hvzq"},
};
var IP = "127.0.0.1";
var PORT = 12345;
var URL = "ws://" + IP + ":" + PORT;
module.exports = function() {
th.mesh({id: idB, ws: {host: IP, port: PORT}}, function(err, meshB) {
assert(err == null);
assert(meshB);
// Accept all incoming links;
meshB.accept = function(from) {
meshB.link(from);
};
// Simple echo service.
meshB.stream(function(link, args, cbAccept) {
var streamBA = cbAccept();
streamBA.on("data", function(chunk) {
streamBA.write(chunk);
});
});
});
};