I have developed a client/server bi-directional communication using dnode.
When a client connects to the server, I keep the connection so the server can use this connection to invoke a method on the client when it needs to.
Sometimes the connection seems to become inactive, I then need to restart the client manually. Could the connection remain active with some specific options ? (I though the reconnect every 3s would do the trick but does not seem to be the case).
服务器也一样。
dnode(function (remote, conn) {
conn.on( connect , function (){ // THIS METHOD IS NEVER CALLED !!! I DON T KNOW WHY
console.log("connection");
});
// Connection starts
conn.on( ready , function () {
// Keep remote in a hash for later usage
...
});
// Connection ends
conn.on( end , function(){
// Remove remote object from hash
...
});
}).listen(5000);
客户:
// Define client functions
dnode(function (remote, conn) {
// Ping
this.ping = function (cb) {
cb("pong");
};
// Other functions
...
}).connect(server, port, { reconnect : 3000});