Beispiel #1
0
        public async Task TryDisconnect()
        {
            if (this.isConnected)
            {
                try
                {
                    DisconnectionPackage dcPackage = new DisconnectionPackage(Username, "Request disconnection");
                    await TrySendObject(dcPackage);

                    this.socket.Shutdown(SocketShutdown.Both);
                    this.socket.Close();
                    this.isConnected = false;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Beispiel #2
0
 public async Task TryDisconnect()
 {
     if (this.isConnected)
     {
         requestDisconnection = true;
         try
         {
             DisconnectionPackage dcPackage = new DisconnectionPackage(Username, "Request disconnection");
             await TrySendObject(dcPackage);
         }
         catch
         {
         }
         finally
         {
             if (this.socket.Connected)
             {
                 Disconnect();
             }
         }
     }
 }