/// <param name="silent">Whether to skip dispatching the disconnection event. Used to cancel the bootstrapping of the client-server connection.</param>
        private void closeSocket(string socketID, bool silent)
        {
            LogClient client = GetClient(socketID);

            if (client == null)
            {
                return;
            }
            try
            {
                client.ClientSocket.Close();
                client.ClientSocket.Dispose();

                if (!silent)
                {
                    // Dispatch Event
                    if (ClientDisconnected != null)
                    {
                        SocketEventArgs args = new SocketEventArgs();
                        args.ClientId      = client.ClientId;
                        args.ClientAddress = client.UniqueAddress;
                        ClientDisconnected(this, args);
                    }
                }
                // Moved to finnaly block: connectedClients.Remove(client.id);
            }
            catch (SocketException)
            {
                // Don't care. Or?
            }
            finally
            {
                connectedClients.Remove(client.UniqueAddress);
            }
        }
 /// <summary>
 /// Server_s the client disconnected.
 /// </summary>
 /// <param name="socketServer">The socket server.</param>
 /// <param name="e">The <see cref="SocketEventArgs"/> instance containing the event data.</param>
 void Server_ClientDisconnected(ILoggerServer socketServer, SocketEventArgs e)
 {
     ConnectedClients.Remove(e.ClientAddress);
 }
        /// <param name="silent">Whether to skip dispatching the disconnection event. Used to cancel the bootstrapping of the client-server connection.</param>
        private void closeSocket(string socketID, bool silent)
        {
            LogClient client = GetClient(socketID);
                if (client == null)
                {
                    return;
                }
                try
                {
                    client.ClientSocket.Close();
                    client.ClientSocket.Dispose();

                    if (!silent)
                    {
                        // Dispatch Event
                        if (ClientDisconnected != null)
                        {
                            SocketEventArgs args = new SocketEventArgs();
                            args.ClientId = client.ClientId;
                            args.ClientAddress = client.UniqueAddress;
                            ClientDisconnected(this, args);
                        }
                    }
                    // Moved to finnaly block: connectedClients.Remove(client.id);
                }
                catch (SocketException)
                {
                    // Don't care. Or?
                }
                finally
                {
                    connectedClients.Remove(client.UniqueAddress);
                }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Server_s the client disconnected.
 /// </summary>
 /// <param name="socketServer">The socket server.</param>
 /// <param name="e">The <see cref="SocketEventArgs"/> instance containing the event data.</param>
 void Server_ClientDisconnected(ILoggerServer socketServer, SocketEventArgs e)
 {
     ConnectedClients.Remove(e.ClientAddress);
 }