コード例 #1
0
        public void Disconnect()
        {
            mLoggedIn    = false;
            ConnectionId = "";

            StopSendTask();
            StopHeartbeat();

            if (mWebSocket != null)
            {
                mWebSocket.OnConnectionOpened -= OnWebSocketConnected;
                mWebSocket.OnConnectionClosed -= OnWebSocketClosed;
                mWebSocket.ProcessMessage     -= ProcessMessage;
                mWebSocket.Disconnect();
                mWebSocket = null;
            }
        }
コード例 #2
0
        public void Connect()
        {
            if (mWebSocket != null)              // already connected or trying to connect
            {
                return;
            }

            Disconnect();             // clean up

            string url = SnipeConfig.Instance.ServiceWebsocketURL;

            DebugLogger.Log("[SnipeClient] WebSocket Connect to " + url);

            mWebSocket = new WebSocketWrapper();
            mWebSocket.OnConnectionOpened += OnWebSocketConnected;
            mWebSocket.OnConnectionClosed += OnWebSocketClosed;
            mWebSocket.ProcessMessage     += ProcessMessage;
            mWebSocket.Connect(url);
        }