Beispiel #1
0
            private void TCPSocketsServerClient_ConnectionLost(CommunicationsLibrary.Services.SocketsDataDistribution.SocketsServerClient sender)
            {
                try
                {
                    //adds to the table of clients which connection went lost in order to further evaluate if
                    //a local client is valid to send data
                    lock (this._DisconnectedTCPsocketServerClientsTable)
                    {
                        this._DisconnectedTCPsocketServerClientsTable.Add(sender.ClientID, sender);
                    }

                    string clientID = sender.ClientID;

                    //removes any event hanlder for the connection object
                    SocketsServerClient client = null;

                    if (this._TCPSocketsServerClientsTable.ContainsKey(clientID))
                    {
                        client = (SocketsServerClient)this._TCPSocketsServerClientsTable[sender.ClientID];
                        client.ConnectionLost -= TCPSocketsServerClient_ConnectionLost;
                    }

                    this.CleanClientDisconnectionsEnvironment();

                    //gets the connection string id and removes from the connections available
                    string connectionPortStringID = "";
                    int    portNumber             = Convert.ToInt32(sender.ServerListeningPort);
                    connectionPortStringID = this.GetConnectionStringID(sender.ServerHostName, portNumber);
                    lock (this._TCPSocketsConnectionStringIDReferenceTable)
                    {
                        this._TCPSocketsConnectionStringIDReferenceTable.Remove(connectionPortStringID);
                    }

                    if (!(client == null))
                    {
                        try
                        {
                            client.DisconnectFromServer();
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            client.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
Beispiel #2
0
 private void Disconnection(CommunicationsLibrary.Services.SocketsDataDistribution.SocketsServerClient sender)
 {
     MessageBox.Show("Connection with Server Lost");
 }