问题出在socket.io客户端。Socket IO发布订阅模式棘手
我想先创建未连接的套接字,并在分配所有的监听器后将其连接到服务器。监听器不能在我的应用程序中的一个地方同步设置,因为存在一些依赖关系。
我知道这是非常正常的行为正常的node.js!只要看看nodejs的套接字!我希望我的架构没有问题。插座IO缺乏documentation,我找不到怎么做我想做的:
var socket = new io.Socket(); //creating empty socket.But this line does not work
//..... socket variable can be passed somewhere .....
//..... to another place in app .....
socket.on('message', callback);
//..... when everyone is ready and subscriben .....
socket.connect('some-url');
'var socket = new io.Socket(); //这是行不通的# – Dan 2012-03-06 11:51:33