Exemplo n.º 1
0
        /// <summary>
        /// Called when a client closes the connection.
        /// </summary>
        /// <param name="tcpConn"></param>
        /// <param name="type"></param>
        private void OnConnectionClosed(TcpConnection tcpConn, ConnectionCloseType type)
        {
            var conn = (Connection)tcpConn;

            if (conn.Name != null)
            {
                this.ClientDisconnected?.Invoke(conn.Name);
            }
        }
Exemplo n.º 2
0
 public void Close(ConnectionCloseType type)
 {
     if (isClosed.Exchange(true))
     {
         return;
     }
     if (IsShutdown == false)
     {
         Shutdown();
     }
     Socket.Close();
     Server.OnConnectionDisconnected(this, type);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Called when the client is disconnected in some way, raises
 /// Closed event.
 /// </summary>
 /// <param name="type"></param>
 protected virtual void OnDisconnect(ConnectionCloseType type)
 {
     this.Disconnected?.Invoke(this, type);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Called when the connection was closed, raises Closed event.
 /// </summary>
 /// <param name="type"></param>
 protected virtual void OnClosed(ConnectionCloseType type)
 {
     this.Closed?.Invoke(this, type);
 }
Exemplo n.º 5
0
 internal void OnConnectionDisconnected(TcpConnection conn, ConnectionCloseType type)
 {
     closeQueue.Enqueue(Tuple.Create(conn, type));
     acceptController.OnDisconnect();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Called when a connection from this communicator to another
        /// one was closed.
        /// </summary>
        /// <param name="tcpClient"></param>
        /// <param name="type"></param>
        private void OnDisconnected(TcpClient tcpClient, ConnectionCloseType type)
        {
            var client = (Client)tcpClient;

            this.Disconnected?.Invoke(client.Name);
        }