有人可以向我解释如何让socket.io客户端连接到服务器A - >断开然后连接到服务器B?
干杯
编辑:这是我遇到问题的代码
login.on('connect', function (data) {
console.log('Connected to login server');
});
login.on('disconnect', function(){
console.log('Disconnected from login server');
});
login.on('login', function (data) {
// set the connection details for the storage server
storage = io.connect('http://'+data.node);
// Disconnect from the login server
login.disconnect();
});
storage.on('connect', function (data) {
console.log('Connected to storage server');
});
Connect上的存储永远不会触发..为什么?
答案 0 :(得分:0)
试试这段代码:
login.on('connect', function (data) {
console.log('Connected to login server');
});
login.on('disconnect', function(){
console.log('Disconnected from login server');
});
login.on('login', function (data) {
// set the connection details for the storage server
storage = io.connect('http://'+data.node);
storage.on('connect', function (data) {
console.log('Connected to storage server');
});
// Disconnect from the login server
login.disconnect();
});