public static void ClassCleanup()
 {
     Task.Delay(500).Wait();
     _cancelSource.Cancel();
     _tcpClient.Dispose();
     _tcpServer.Dispose();
 }
Exemple #2
0
        private void ConnectRA()
        {
            TCManager manager = TCManager.Instance;

            if (manager.RAClient != null)
            {
                ((TCPClient)manager.RAClient).Dispose();
            }

            manager.RAClient = new TCPClient(Settings.Default.RAHost, Settings.Default.RAPort);

            TCPClient client = (TCPClient)manager.RAClient;

            try
            {
                client.Connect();
                client.TCConnected       += _raClient_TCConnected;
                client.TCDisconnected    += _raClient_TCDisconnected;
                client.TCMessageReceived += _raClient_TCMessageReceived;
            }
            catch (Exception ex)
            {
                client.Dispose();

                MessageBoxEx.Show(this, "Could not connect to RA! (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        static void ClientDisconnected(TCPClient pClient)
        {
            var sClient = LoginClients.Find(s => s.ClientID == pClient.ClientID);

            Log.Write(LogLevel.Warning, "Client '{0}' disconnected from LoginServer", pClient.ClientID);

            sClient.Dispose();
            pClient.Dispose();
        }
Exemple #4
0
 public void Dispose()
 {
     TCPClient.Close();
     TCPClient.Dispose();
     Writer.Close();
     Writer.Dispose();
     Reader.Close();
     Reader.Dispose();
 }
Exemple #5
0
        static void ClientDisconnected(TCPClient pClient)
        {
            var sClient = GameClients.Find(s => s.SessionID == pClient.ClientID);

            Log.Write(LogLevel.Warning, "Client '{0}' disconnected from Shard01", pClient.ClientID);

            GameClients.Remove(sClient);

            sClient.Dispose();
            pClient.Dispose();
        }
Exemple #6
0
 public void Dispose()
 {
     if (_sessionToken != 0)
     {
         TCPClientDataSend(new PUserLogout
         {
             SessionToken = _sessionToken
         });
     }
     _tcpClient.Dispose();
 }
        /// <summary>
        /// Disconnect from server
        /// </summary>
        public void Disconnect()
        {
            SocketErrorCodes err = new SocketErrorCodes();

            try
            {
                _manualDisconnect = true;
                _tcpClient.Dispose();
                err = _tcpClient.DisconnectFromServer();
                Debug("Disconnect attempt: " + _tcpClient.AddressClientConnectedTo, ErrorLevel.Notice, err.ToString());
            }
            catch (Exception e)
            {
                Debug(e.Message, ErrorLevel.Error, err.ToString());
            }
        }
        /// <summary>
        ///  Internal call to close up client. ALWAYS use this when disconnecting.
        /// </summary>
        void Cleanup()
        {
            IsTryingToConnect = false;

            if (Client != null)
            {
                //SecureClient.DisconnectFromServer();
                Debug.Console(2, this, "Disconnecting Client {0}", DisconnectCalledByUser ? ", Called by user" : "");
                Client.SocketStatusChange -= Client_SocketStatusChange;
                Client.Dispose();
                Client = null;
            }
            if (ConnectFailTimer != null)
            {
                ConnectFailTimer.Stop();
                ConnectFailTimer.Dispose();
                ConnectFailTimer = null;
            }
        }
        public void SendMsg(string TCPMessage)
        {
            SocketErrorCodes s;

            if (RIO_TcpClient.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED)  // the sSocketConnect might have closed on us or timed out
            {
                if (Debug)
                {
                    ErrorLog.Notice("RIO.Driver.Closing Stale Socket");
                }
                RIO_TcpClient.Dispose();
                if (Debug)
                {
                    ErrorLog.Notice("RIO.Driver.ReconnectingSocket..");
                }
                SocketConnect();
            }
            try
            {
                string msg = TCPMessage + "\r";

                if (Debug)
                {
                    ErrorLog.Notice("RIO.Driver.CMD: " + msg);
                }

                Byte[] data = System.Text.Encoding.ASCII.GetBytes(msg);

                s = RIO_TcpClient.SendData(data, data.Length);

                if (Debug)
                {
                    ErrorLog.Notice("RIO.Driver.Send: " + s.ToString());
                }

                RIO_TcpClient.ReceiveData();  ///clear down buffer.
            }
            catch (SocketException e)
            {
                ErrorLog.Error("RIO.Driver SocketException: {0}", e);
            }
        }
 protected virtual void Terminate()
 {
     try
     {
         //if (ControlCEC != null)
         //ControlCEC = null;
         if (ControlIR != null)
         {
             ControlIR.UnRegister();
         }
         if (ControlRelay != null)
         {
             ControlRelay.UnRegister();
         }
         if (ControlSerial != null)
         {
             ControlSerial.UnRegister();
         }
         if (ControlTCP != null)
         {
             ControlTCP.Dispose();
         }
         if (ControlUDP != null)
         {
             ControlUDP.Dispose();
         }
         if (ControlVP != null)
         {
             ControlVP.UnRegister();
         }
     }
     catch (Exception e)
     {
         ErrorLog.Exception("Exception terminating " + this.Name, e);
     }
 }
Exemple #11
0
 public void Dispose()
 {
     cli.Dispose();
     cli = null;
 }
Exemple #12
0
 public static void ClassCleanup()
 {
     _cancelSource.Cancel();
     _tcpClient.Dispose();
     _tcpServer.Dispose();
 }
Exemple #13
0
        static void ClientDisconnected(TCPClient pClient)
        {
            Log.Write(LogLevel.Warning, "Client '{0}' disconnected from TimeServer", pClient.ClientID);

            pClient.Dispose();
        }
 /// <summary>
 /// Disconnects the TCP connection that was established to the PLC.
 /// </summary>
 public void DisconnectFromPLC()
 {
     // Call the dispose() method to close the stream and connection.
     TCPClient.Dispose();
     logger.Info("Disposed of the TCP Client.");
 }