Detect lost connection from SignalR Core connectio

2019-07-11 18:36发布

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条回答
混吃等死
2楼-- · 2019-07-11 19:20

Use onclose:

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

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

查看更多
登录 后发表回答