예제 #1
0
 protected virtual void OnDispose()
 {
     try
     {
         object data = DequeueSendMessage();
         while (data != null)
         {
             if (data is IBuffer buffer)
             {
                 BeetleX.Buffers.Buffer.Free(buffer);
             }
             data = DequeueSendMessage();
         }
         SendEventArgs?.Dispose();
         SendEventArgs?.Clear();
         ReceiveEventArgs?.Dispose();
         ReceiveEventArgs?.Clear();
         mReceiveArgs.Server  = null;
         mReceiveArgs.Session = null;
         mBaseNetStream.Dispose();
         if (mSslStream != null)
         {
             mSslStream.Dispose();
         }
         Server.CloseSession(this);
         ListenHandler     = null;
         ReceiveDispatcher = null;
         if (Packet != null)
         {
             Packet.Dispose();
         }
         ((IDisposable)Tag)?.Dispose();
         OnDisposeProperties();
         ((IDisposable)mToken)?.Dispose();
     }
     catch
     {
     }
     finally
     {
         Tag    = null;
         mToken = null;
     }
 }
예제 #2
0
 protected virtual void OnDispose()
 {
     try
     {
         object data = DequeueSendMessage();
         while (data != null)
         {
             if (data is IBuffer buffer)
             {
                 BeetleX.Buffers.Buffer.Free(buffer);
                 //((IBuffer)data).Free();
             }
             data = DequeueSendMessage();
         }
         SendEventArgs?.Dispose();
         SendEventArgs?.Clear();
         ReceiveEventArgs?.Dispose();
         ReceiveEventArgs?.Clear();
         mReceiveArgs.Server  = null;
         mReceiveArgs.Session = null;
         mBaseNetStream.Dispose();
         if (mSslStream != null)
         {
             mSslStream.Dispose();
         }
         Server.CloseSession(this);
         //Server = null;
         ListenHandler     = null;
         ReceiveDispatcher = null;
         if (Packet != null)
         {
             Packet.Dispose();
         }
         mProperties.Clear();
     }
     catch
     {
     }
 }