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());
        }
Ejemplo n.º 2
0
        private void SocketStatusHandler(TCPServer server, uint clientindex, SocketStatus status)
        {
            ErrorLog.Notice("TCPServer Socket Status Change Handler. Status = " + status.ToString());
            if (status != SocketStatus.SOCKET_STATUS_CONNECTED)
            {
                if (Thread.CurrentThread.ThreadState == Thread.eThreadStates.ThreadAborting)
                {
                    // Thread aborted so exit
                    return;
                }

                ErrorLog.Notice("Starting reconnect timer");
                ReconnectTimer = new CTimer(new CTimerCallbackFunction(ReconnectCallback), 5000);
            }
            return;
        }
Ejemplo n.º 3
0
        private void SocketStatusHandler(TCPClient client, SocketStatus status)
        {
            ErrorLog.Notice(this.Name + " - Socket Status Handler - status = " + status.ToString());

            if (status != SocketStatus.SOCKET_STATUS_CONNECTED)
            {
                ErrorLog.Notice(this.Name + " - Link not connected");
                if (Thread.CurrentThread.ThreadState == Thread.eThreadStates.ThreadAborting)
                {
                    ErrorLog.Notice(this.Name + " - Link thread aborting");
                }
                else
                {
                    ErrorLog.Notice(this.Name + " - Starting reconnect timer");
                    ReconnectTimer = new CTimer(new CTimerCallbackFunction(ReconnectCallback), 30000);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// event that triggers when socket status changes, send status to s+
        /// </summary>
        /// <param name="tcpClient">tcp client</param>
        /// <param name="sockStatus">socket status code</param>
        private void OnSocketStatusChange(TCPClient tcpClient, SocketStatus sockStatus)
        {
            if (_sockStatusDict.ContainsKey(sockStatus))
            {
                ConnectionStatus(sockStatus.ToString(), _sockStatusDict[sockStatus]);
            }

            if (sockStatus == SocketStatus.SOCKET_STATUS_CONNECTED)
            {
                _tcpClient.ReceiveDataAsync(OnDataReceiveEventCallback);
                ConnectedFbStatus(1);
                _manualDisconnect = false;
            }
            else
            {
                ConnectedFbStatus(0);
                TryReconnect();
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// TCP Server (Unsecure) Socket Status Change Callback
 /// </summary>
 /// <param name="mySecureTCPServer"></param>
 /// <param name="clientIndex"></param>
 /// <param name="serverSocketStatus"></param>
 void UnsecureServer_SocketStatusChange(TCPServer server, uint clientIndex, SocketStatus serverSocketStatus)
 {
     Debug.Console(2, "Client at {0} ServerSocketStatus {1}",
                   server.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex), serverSocketStatus.ToString());
     if (server.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED)
     {
         if (SharedKeyRequired && !WaitingForSharedKey.Contains(clientIndex))
         {
             WaitingForSharedKey.Add(clientIndex);
         }
         if (!ConnectedClientsIndexes.Contains(clientIndex))
         {
             ConnectedClientsIndexes.Add(clientIndex);
         }
     }
     else
     {
         if (ConnectedClientsIndexes.Contains(clientIndex))
         {
             ConnectedClientsIndexes.Remove(clientIndex);
         }
         if (HeartbeatRequired && HeartbeatTimerDictionary.ContainsKey(clientIndex))
         {
             HeartbeatTimerDictionary.Remove(clientIndex);
         }
     }
     if (UnsecureServer.ServerSocketStatus.ToString() != Status)
     {
         onConnectionChange();
     }
 }
Ejemplo n.º 6
0
        void socket_SocketStatusChange(TCPClient myTCPClient, SocketStatus clientSocketStatus)
        {
            CrestronConsole.PrintLine("{0}.SocketStatusChange, device at {1}, {2}", this.GetType().Name, Socket.AddressClientConnectedTo, clientSocketStatus.ToString());

            if (clientSocketStatus == SocketStatus.SOCKET_STATUS_NO_CONNECT)
            {
                if (shouldReconnect)
                {
                    ErrorLog.Warn("Socket disconnected from device at {0}", Socket.AddressClientConnectedTo);
                }
                if (SocketConnectionEvent != null)
                {
                    SocketConnectionEvent(this, Socket.ClientStatus);
                }
                if (shouldReconnect)
                {
                    this.Connect(shouldReconnect);
                }
            }
        }