-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
35 lines (29 loc) · 905 Bytes
/
test.js
File metadata and controls
35 lines (29 loc) · 905 Bytes
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
const neffos = require('neffos.js');
const wsURL = "ws://127.0.0.1:8086/echo";
async function runExample() {
try {
console.log("start runExample.");
const conn = await neffos.dial(wsURL, {
default: { // "default" namespace.
_OnNamespaceConnected: function (nsConn, msg) {
console.log("connected to namespace: " + msg.Namespace);
},
_OnNamespaceDisconnect: function (nsConn, msg) {
console.log("disconnected from namespace: " + msg.Namespace);
},
chat: function (nsConn, msg) {
console.log('====msg=======',msg.Body);
}
}
},{
reconnect: 2000,
});
const nsConn = await conn.connect("default");
/*setInterval(function(){
}, 1000);*/
nsConn.emit("chat",JSON.stringify({Name:"test",ID:"10bf0d11"}))
} catch (err) {
console.error(err);
}
}
runExample()