Пример #1
0
        /// <summary>
        /// Called when a client has connected to the server.
        /// </summary>
        /// <param name="socket">The web-socket of the client.</param>
        /// <returns>Awaitable Task.</returns>
        public virtual async Task OnConnected(WebSocket socket)
        {
            WebSocketConnectionManager.AddSocket(socket);

            await SendMessageAsync(socket, new Message()
            {
                MessageType = MessageType.ConnectionEvent,
                Data        = WebSocketConnectionManager.GetId(socket)
            }).ConfigureAwait(false);
        }
Пример #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(WebSocket socket)
 {
     await WebSocketConnectionManager.RemoveSocket(WebSocketConnectionManager.GetId(socket)).ConfigureAwait(false);
 }