private void Terminate()
 {
     _StoppingFlag = true;
     _TCPServer.SocketStatusChange -= SocketStatusHandler;
     _TCPServer.DisconnectAll();
     _TCPServer.Stop();
 }
Esempio n. 2
0
        /// <summary>
        /// Disposes of resources.
        /// </summary>
        public void Dispose()
        {
            if (tcpServer != null)
            {
                tcpServer.Stop();
                tcpServer.DisconnectAll();
                tcpServer = null;
            }

            if (secureTcpServer != null)
            {
                secureTcpServer.Stop();
                secureTcpServer.DisconnectAll();
                secureTcpServer = null;
            }
        }
        private static void tcpServer_SocketStatusChange(TCPServer myTCPServer, uint clientIndex, SocketStatus serverSocketStatus)
        {
            if (debug > 0)
            {
                CrestronConsole.Print("\n Catch Connect SocketStatusChange serverSocketStatus: {0} for index: {1}", serverSocketStatus.ToString(), clientIndex.ToString());
            }

            ushort online = 0;

            switch (serverSocketStatus)
            {
            case SocketStatus.SOCKET_STATUS_CONNECTED:
                online = 1;
                ProcessQueue();
                break;

            case SocketStatus.SOCKET_STATUS_NO_CONNECT:
                online = 0;
                myTCPServer.DisconnectAll();
                StartListening();
                break;

            default:
                break;
            }
            OnServiceEvent(online, (ushort)serverSocketStatus, serverSocketStatus.ToString());
        }
Esempio n. 4
0
 void tcp_SocketStatusChange(TCPServer myTCPServer, uint clientIndex, SocketStatus serverSocketStatus)
 {
     if (serverSocketStatus == SocketStatus.SOCKET_STATUS_LINK_LOST || serverSocketStatus == SocketStatus.SOCKET_STATUS_NO_CONNECT)
     {
         tcp.DisconnectAll();
         this.Listen();
     }
     // throw new NotImplementedException();
 }
Esempio n. 5
0
        void server_SocketStatusChange(TCPServer server, uint clientIndex, SocketStatus status)
        {
            ErrorLog.Notice("Server Socket Status Is {0} - {1}", server.ServerSocketStatus, server.State);

            if ((server.ServerSocketStatus == SocketStatus.SOCKET_STATUS_SOCKET_NOT_EXIST) || (server.ServerSocketStatus == SocketStatus.SOCKET_STATUS_NO_CONNECT))
            {
                server.DisconnectAll();
                clients.Clear();
            }
        }
Esempio n. 6
0
 public void Stop()
 {
     CloudLog.Notice("Stopping {0} instance on TCP port {1}", GetType().Name, _socket.PortNumber);
     if (_socket != null)
     {
         var message = Encoding.ASCII.GetBytes("Closing connections!\r\n");
         SendToAll(message, 0, message.Length);
         _socket.DisconnectAll();
     }
 }
 /// <summary>
 /// Disconnect All Clients
 /// </summary>
 public void DisconnectAllClients()
 {
     Debug.Console(2, "Disconnecting All Clients");
     if (SecureServer != null)
     {
         SecureServer.DisconnectAll();
     }
     if (UnsecureServer != null)
     {
         UnsecureServer.DisconnectAll();
     }
     onConnectionChange();
     onServerStateChange(); //State shows both listening and connected
 }
Esempio n. 8
0
 /**
  * Method: stopServer
  * Access: public
  * @return: void
  * Description: Disconnect all socket clients and remove event handlers.
  */
 public void stopServer()
 {
     Server.DisconnectAll();
     Server.SocketStatusChange -= socketStatusHandler;
     Debug.print("Stopped Server.");
 }