我使用内置在sockjs上的vertxbus,我有一个基本的问题。
当我致电' onopen'第一次为了建立连接,我怎么知道服务器已关闭?
此时我打电话给#on; onopen'并传递一个回调函数 - 如果服务器关闭,方法会被卡住并且根本不会返回。
谢谢!
答案 0 :(得分:0)
您可以查看code ,我正在使用EventBus。
这是参考代码
this.eventBus = new EventBus(this.URL);
this.eventBus.onopen = (e) => {
this._opened = true;
console.log("open connection");
this.callHandlers('open', e);
this.eventBus.publish("http://localhost:8082", "USER LOGIN INFO");
this.eventBus.registerHandler("http://localhost:8081/pushNotification", function (error, message) {
console.log(message.body);
//$("<div title='Basic dialog'>Test message</div>").dialog();
});
}
this.eventBus.onclose = (e) => {
this.callHandlers('close', e);
}
}