Пример #1
0
        public void DisconnectAndDispatch(Action <ExpandoObject> event_to_dispatch)
        {
            if (DebugEnabled)
            {
//#if DEBUG
                Debug.Log("[SnipeClient] DisconnectAndDispatch");
            }
//#endif
            if (mTCPClient != null)
            {
                mTCPClient.Dispose();
                mTCPClient = null;
            }

            if (mWebSocketClient != null)
            {
                mWebSocketClient.Dispose();
                mWebSocketClient = null;
            }

            mConnected = false;
            mLoggedIn  = false;

            mHeartbeatTriggerTime       = 0.0f;
            mCheckConnectionTriggerTime = 0.0f;

            if (event_to_dispatch != null)
            {
                DispatchEvent(event_to_dispatch);
            }

            ConnectionId = "";
        }
Пример #2
0
 private void ConnectTCP()
 {
     if (mTCPClient == null)
     {
         mTCPClient = new SnipeTCPClient();
         mTCPClient.OnConnectionSucceeded = OnTCPConnectionSucceeded;
         mTCPClient.OnConnectionFailed    = OnTCPConnectionFailed;
         mTCPClient.OnConnectionLost      = OnConnectionLost;
         mTCPClient.OnMessageReceived     = OnMessageReceived;
     }
     mTCPClient.Connect(mConnectionHost, mConnectionPort);
 }
Пример #3
0
        private void OnWebSocketConnectionSucceeded()
        {
            if (mTCPClient != null)
            {
                mTCPClient.Dispose();
                mTCPClient = null;
            }

            mConnected     = true;
            mClientKeySent = false;
            mLoggedIn      = false;

            mCheckConnectionTriggerTime = 0.0f;
            ResetHeartbeatTime();

            DispatchEvent(ConnectionSucceeded);
        }