コード例 #1
0
 /// <summary>
 /// Close and dispose the socket client handler.
 /// </summary>
 public void Dispose()
 {
     this.Close();
     if (this.receiveQueue != null)
     {
         this.receiveQueue.Dispose();
         this.receiveQueue = null;
     }
     if (this.cancellationToken != null)
     {
         this.cancellationToken.Dispose();
         this.cancellationToken = null;
     }
     if (this.socket != null)
     {
         socket.Dispose();
         socket = null;
     }
 }
コード例 #2
0
 /// <summary>
 /// Constructor for a socket client handler on SSL
 /// </summary>
 /// <param name="handler">The socket handler</param>
 /// <param name="stream">The ssl stream</param>
 /// <param name="useReceiveQueue">If true the message receiving is throw a queue, otherwise each message is handle by a different thread</useReceiveQueue>
 public AbstractTcpSocketClientHandler(Socket handler, SslStream stream, bool useReceiveQueue)
     : base()
 {
     if (stream != null)
     {
         this.socket = new SSLSocket(handler, stream);
     }
     else
     {
         this.socket = new TcpSocket(handler);
     }
     // If the socket client handler has to use the receive queue, the necessary classes are created
     if (useReceiveQueue)
     {
         receiveQueue      = new BlockingCollection <ReceiveMessageStateObject>();
         cancellationToken = new CancellationTokenSource();
         // The dereive dequeuer is started
         this.dequeuerThread = new Thread(new ThreadStart(this.ReceiveDequeuer));
         this.dequeuerThread.Start();
     }
 }
コード例 #3
0
 /// <summary>
 /// Constructor for a socket client handler on SSL
 /// </summary>
 /// <param name="handler">The socket handler</param>
 /// <param name="stream">The ssl stream</param>
 /// <param name="useReceiveQueue">If true the message receiving is throw a queue, otherwise each message is handle by a different thread</useReceiveQueue>
 public AbstractTcpSocketClientHandler(Socket handler, SslStream stream, bool useReceiveQueue)
     : base()
 {
     if (stream != null)
     {
         this.socket = new SSLSocket(handler, stream);
     }
     else
     {
         this.socket = new TcpSocket(handler);
     }
     // If the socket client handler has to use the receive queue, the necessary classes are created
     if (useReceiveQueue)
     {
         receiveQueue = new BlockingCollection<ReceiveMessageStateObject>();
         cancellationToken = new CancellationTokenSource();
         // The dereive dequeuer is started
         this.dequeuerThread = new Thread(new ThreadStart(this.ReceiveDequeuer));
         this.dequeuerThread.Start();
     }
 }
コード例 #4
0
 /// <summary>
 /// Close and dispose the socket client handler.
 /// </summary>
 public void Dispose()
 {
     this.Close();
     if (this.receiveQueue != null)
     {
         this.receiveQueue.Dispose();
         this.receiveQueue = null;
     }
     if (this.cancellationToken != null)
     {
         this.cancellationToken.Dispose();
         this.cancellationToken = null;
     }
     if (this.socket != null)
     {
         socket.Dispose();
         socket = null;
     }
 }