我正在使用SingalR OWIN項目並一次查看limit the number of connected clients
。SignalR限制連接數
我有下面的代碼追蹤連接數:
public override Task OnConnected()
if (ConnectionManager.IsAllowed) // checks number of connected clients < 3
{
ConnectionManager.connectedClients++;
_log.Debug("Connected = " + ConnectionManager.connectedClients);
return base.OnConnected();
}
else
{
return null; // I thought this would reject the incoming connection
// but it does not.
}
}
有誰知道我需要做的,拒接新的連接?我在網上找不到任何例子。
任何建議將是偉大的。
謝謝。
感謝您的迴應,當OnConnected()返回任務類型時,我將如何返回布爾知道? –
我已經添加了一些到我的答案。 –
感謝您的建議,我已經實施了上述措施,並從onConnected事件中撤銷了授權責任。 –