Detect lost connection from SignalR Core connection

北战南征 提交于 2019-12-23 12:43:37

问题


I'm trying to detect when a SignalR Core connection is lost so that I can create a new one or at least warn the user.

connection.on('closed', data => {
    alert('Connection Closed');
});

This seems to have no effect. The messages stop arriving but this handler isn't fired.

On a related note, where is the documentation for event handling for the new version of this library?


回答1:


Use onclose:

connection.onclose(function (e) {
    alert('Connection Closed');
}

There's no documentation yet, but a handful of samples on GitHub.



来源:https://stackoverflow.com/questions/49864154/detect-lost-connection-from-signalr-core-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!