public void AddWebSocketClient(string connectionId, WebSocketClient socket)
 {
     Clients.TryAdd(connectionId, socket);
 }
Exemple #2
0
 /// <summary>
 /// Called when a client has disconnected from the server.
 /// </summary>
 /// <param name="socket">The web-socket of the client.</param>
 /// <returns>Awaitable Task.</returns>
 public virtual async Task OnDisconnected(WebSocketClient client)
 {
     var connectionId = WebSocketConnectionManager.GetConnectionId(client);
     await WebSocketConnectionManager.RemoveClient(connectionId);
 }
 public string GetConnectionId(WebSocketClient client)
 {
     return(Clients.FirstOrDefault(p => p.Value.Equals(client)).Key);
 }
Exemple #4
0
 /// <summary>
 /// Called when a client has connected to the server.
 /// </summary>
 /// <param name="client">The web-socket of the client.</param>
 /// <returns>Awaitable Task.</returns>
 public virtual Task OnConnected(string connectionId, WebSocketClient client, HttpContext context)
 {
     WebSocketConnectionManager.AddWebSocketClient(connectionId, client);
     return(Task.CompletedTask);
 }