사용자가 페이지를 새로 고치면 새 연결로 처리됩니다. 연결 끊기가 시간 초과를 기반으로 한 것이 맞습니다.
SignalR.Hubs.IConnected
및
SignalR.Hubs.IDisconnect
을 구현하여 허브에서 연결/재 연결 및 연결 끊기 이벤트를 처리 할 수 있습니다.
위의 내용은 SignalR 0.5.x를 참조했습니다.
이 SignalR 1.0에서
public class ContosoChatHub : Hub
{
public override Task OnConnected()
{
// Add your own code here.
// For example: in a chat application, record the association between
// the current connection ID and user name, and mark the user as online.
// After the code in this method completes, the client is informed that
// the connection is established; for example, in a JavaScript client,
// the start().done callback is executed.
return base.OnConnected();
}
public override Task OnDisconnected()
{
// Add your own code here.
// For example: in a chat application, mark the user as offline,
// delete the association between the current connection id and user name.
return base.OnDisconnected();
}
public override Task OnReconnected()
{
// Add your own code here.
// For example: in a chat application, you might have marked the
// user as offline after a period of inactivity; in that case
// mark the user as online again.
return base.OnReconnected();
}
}