Ejemplo n.º 1
0
 private void Stop()
 {
     if (this.m_client != null)
     {
         this.m_client.Close();
         this.m_client = null;
     }
     if (this.m_readThread != null)
     {
         this.m_readThread.Stop();
         this.m_readThread = null;
     }
     if (this.m_writeThread != null)
     {
         this.m_writeThread.Stop();
         this.m_writeThread = null;
     }
     this.m_dispatcher.Clear();
 }
Ejemplo n.º 2
0
 public void Stop()
 {
     if (this.m_client != null)
     {
         rdtDebug.Debug(this, "Stopping connection", new object[0]);
         this.m_client.Close();
         this.m_client = null;
     }
     if (this.m_readThread != null)
     {
         this.m_readThread.Stop();
         this.m_readThread = null;
     }
     if (this.m_writeThread != null)
     {
         this.m_writeThread.Stop();
         this.m_writeThread = null;
     }
     this.m_dispatcher.Clear();
     this.SetState(State.None);
 }
Ejemplo n.º 3
0
        private void OnConnecting(double delta)
        {
            if (this.m_currentAsyncResult.IsCompleted)
            {
                try
                {
                    this.m_client.EndConnect(this.m_currentAsyncResult);
                    rdtDebug.Debug(this, "Connected to server", new object[0]);
                    this.m_writeThread = new rdtWriteMessageThread(this.m_client.GetStream(), "rdtClient");
                    this.m_readThread  = new rdtReadMessageThread(this.m_client.GetStream(), this.m_dispatcher, new Action <rdtTcpMessage>(this.OnReadMessage), "rdtClient");
                    this.SetState(State.Connected);
                }
                catch (SocketException exception)
                {
                    switch (exception.ErrorCode)
                    {
                    case 0x274c:
                        rdtDebug.Info("RemoteDebug: Connection timed out", new object[0]);
                        break;

                    case 0x274d:
                        rdtDebug.Info("RemoteDebug: Connection was refused", new object[0]);
                        break;

                    default:
                        rdtDebug.Info("RemoteDebug: Failed to connect to server (error code " + exception.ErrorCode + ")", new object[0]);
                        break;
                    }
                    this.Stop();
                }
                catch (ObjectDisposedException)
                {
                    rdtDebug.Error(this, "Client was disposed", new object[0]);
                    this.Stop();
                }
            }
        }
Ejemplo n.º 4
0
 private void OnConnecting()
 {
     if (this.m_currentAsyncResult.IsCompleted)
     {
         try
         {
             this.m_client = this.m_listener.EndAcceptTcpClient(this.m_currentAsyncResult);
             rdtDebug.Debug(this, "Client connected from " + this.m_client.Client.RemoteEndPoint, new object[0]);
             this.m_readThread  = new rdtReadMessageThread(this.m_client.GetStream(), this.m_dispatcher, new Action <rdtTcpMessage>(this.OnReadMessage), "rdtServer");
             this.m_writeThread = new rdtWriteMessageThread(this.m_client.GetStream(), "rdtServer");
             this.SetState(State.Connected);
         }
         catch (SocketException exception)
         {
             rdtDebug.Error(this, "Socket exception while client was connecting (error code " + exception.ErrorCode + ")", new object[0]);
             this.StartListening();
         }
         catch (ObjectDisposedException)
         {
             rdtDebug.Error(this, "Tcp listener was disposed", new object[0]);
             this.StartListening();
         }
     }
 }