Exemplo n.º 1
0
        public int SendCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket SendCallback.");
                }

                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket ReceiveAsync resultCodes: \r\n" + resultCodes.ToString());
                }
            }
            catch (Exception e)
            {
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket SendCallback exception: " + e.Message);
                }
                return(-1);
            }

            return(0);
        }
 private int DisconnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error, object obj)
 {
     if (obj is bool &&
         ((bool)obj))
     {
         // This means we called disconnect internally,
         // report this as being disconnected to everyone else
         UpdateConnectionStatus(WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_ERROR, "DisconnectCallback");
     }
     else
     {
         UpdateConnectionStatus(error, "DisconnectCallback");
     }
     try
     {
         if (EnableLogging)
         {
             Log(string.Format("WebSocketTransport : Disconnected - {0}", error));
         }
         ConnectClient();
     }
     catch (Exception e)
     {
         if (EnableLogging)
         {
             Log(string.Format("WebSocketTransport : Disconnect Callback Exception: {0}", e.Message));
         }
     }
     return((int)error);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="length"></param>
        /// <param name="opcode"></param>
        /// <param name="err"></param>
        int Websocket_ReceiveCallback(byte[] data, uint length, WebSocketClient.WEBSOCKET_PACKET_TYPES opcode,
                                      WebSocketClient.WEBSOCKET_RESULT_CODES err)
        {
            if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME)
            {
                var rx = System.Text.Encoding.UTF8.GetString(data, 0, (int)length);
                if (rx.Length > 0)
                {
                    ParseStreamRx(rx);
                }
                WSClient.ReceiveAsync();
            }

            else if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__CLOSE)
            {
                Debug.Console(1, this, "Websocket disconnect received from remote");
                CleanUpWebsocketClient();
            }
            else
            {
                Debug.Console(1, this, "websocket rx opcode/err {0}/{1}", opcode, err);
                WSClient.ReceiveAsync();
            }
            return(0);
        }
Exemplo n.º 4
0
 public void Disconnect()
 {
     resultCodes = wsc.Disconnect();
     if (debug > 0)
     {
         CrestronConsole.Print("\n Websocket Disconnect resultCodes: \r\n" + resultCodes.ToString());
     }
 }
Exemplo n.º 5
0
        private int SendCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            if (OnSend != null)
            {
                OnSend((short)error);
            }

            return((int)error);
        }
Exemplo n.º 6
0
        private int DisconnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error, Object obj)
        {
            if (OnDisconnect != null)
            {
                OnDisconnect((short)error);
            }

            return((int)error);
        }
Exemplo n.º 7
0
        public void Connect()
        {
            try
            {
                wsc.Port    = port;
                wsc.URL     = host;
                resultCodes = wsc.Connect();
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket resultCodes: " + resultCodes.ToString());
                }

                if (resultCodes == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
                {
                    CrestronConsole.PrintLine("\n Websocket Connect WEBSOCKET_CLIENT_SUCCESS: " + host + ":" + port.ToString());
                    keepAliveMessageReceived = false;
                    keepAliveCounter         = 0;
                    keepAliveReconnect       = false;
                    keepAliveTimerRepeatTime = 5000;
                    keepAliveTimer.Reset(1000, keepAliveTimerRepeatTime);
                    if (debug > 0)
                    {
                        CrestronConsole.PrintLine("\n Websocket connected.");
                    }
                    resultCodes = wsc.ReceiveAsync();

                    if (debug > 0)
                    {
                        CrestronConsole.Print("\n Websocket ReceiveAsync resultCodes: " + resultCodes.ToString());
                    }
                }
                else if (resultCodes.ToString().Contains("WEBSOCKET_CLIENT_ALREADY_CONNECTED"))
                {
                    if (debug > 0)
                    {
                        CrestronConsole.Print("\n Websocket re-initialize...");
                    }
                    wsc.Disconnect();
                }
                else
                {
                    if (debug > 0)
                    {
                        CrestronConsole.Print("\n Websocket could not connect to server.  Connect return code: " + resultCodes.ToString());
                    }
                    Disconnect();
                }
            }
            catch (Exception e)
            {
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket Connect exception: " + e.Message);
                }
                Disconnect();
            }
        }
Exemplo n.º 8
0
        private int ConnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            if (OnConnect != null)
            {
                OnConnect((short)error);
            }

            wsc.ReceiveAsync();

            return((int)error);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        int Websocket_DisconnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code, object o)
        {
            Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Websocket disconnected with code: {0}", code);

            if (ServerHeartbeatCheckTimer != null)
            {
                ServerHeartbeatCheckTimer.Stop();
            }
            // Start the reconnect timer
            StartServerReconnectTimer();
            return(0);
        }
Exemplo n.º 10
0
 //Websocket Callback functions
 public int SendCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
 {
     try
     {
         MyWSConnection.ReceiveAsync();
     }
     catch (Exception e)
     {
         CrestronConsole.PrintLine("SendCallback Error" + e.ToString());
         return(-1);
     }
     return(0);
 }
Exemplo n.º 11
0
        private int WebSocketCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                webSocketClient.ReceiveAsync();
            }
            catch (Exception)
            {
                return(-1);
            }

            return(0);
        }
Exemplo n.º 12
0
        /// <summary>
        /// The Following Three Methods are for the Websocket Listener
        /// </summary>
        /// <param name="error"></param>
        /// <returns></returns>
        public int SendCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                ret = wsc.ReceiveAsync();
            }
            catch (Exception e)
            {
                return(-1);
            }

            return(0);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Connect to the Pushbullet Websocket to monitor for Pushes
        /// </summary>
        public void connect()
        {
            wsc.URL = "wss://stream.pushbullet.com/websocket/" + Access_Code;
            wrc     = wsc.Connect();

            if (wrc == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
            {
                CrestronConsole.PrintLine("Websocket connected \r\n");
            }
            else
            {
                CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + wrc.ToString());
            }
            getUserInfo();
        }
Exemplo n.º 14
0
        /// <summary>
        /// The Following Three Methods are for the Websocket Listener
        /// </summary>
        /// <param name="error"></param>
        /// <returns></returns>
        public int _SendCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
//            CrestronConsole.PrintLine("SendCallBack\r\n");
            try
            {
                PBSocketResult = PBSocket.ReceiveAsync();
                //CrestronConsole.Print("SendCallBack : " + ret + "\n");
            }
            catch (Exception e)
            {
                return(-1);
            }

            return(0);
        }
Exemplo n.º 15
0
 static int hbWebSocketClient_OnOpen(WebSocketClient.WEBSOCKET_RESULT_CODES result)
 {
     if (result == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
     {
         _hbWebSocketClient.ReceiveAsync();
         _hbWebSocketClientConnected = true;
         HBWebSocketClientConnectionEvent(new EventArgs());
     }
     else
     {
         _hbWebSocketClientConnected = false;
         hbWebSocketClient_OnClose(WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_ERROR, null);
     }
     return(0);
 }
Exemplo n.º 16
0
 public int try_to_connect()
 {
     try
     {
         ret = ws_client.Connect();
         if (ping_count >= 2)
         {
             ping_count = 2;
         }
     }
     catch (Exception ex) {
         CrestronConsole.PrintLine("[WSClient.try_to_connect] exception : {0}", ex.ToString());
     }
     return((int)ret);
 }
Exemplo n.º 17
0
 public void Connect(String Url)
 {
     myWSC.URL = Url;
     CrestronConsole.PrintLine(myWSC.URL);
     error = myWSC.Connect();
     if (error == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
     {
         UpdateSocketStatus(1);
         CrestronConsole.PrintLine("Websocket connected \r\n");
     }
     else
     {
         CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + error.ToString());
     }
 }
Exemplo n.º 18
0
        private int connectWebsocket(WebSocketClient.WEBSOCKET_RESULT_CODES err)
        {
            debug("websocket error = " + err);
            if (err == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
            {
                online = true;
                debug("Connected");
                wsCli.ReceiveAsync();
            }
            else
            {
                online = false;
                debug("WebSocket offline");
            }

            return(0);
        }
        private int ClientSendCallBack(WebSocketClient.WEBSOCKET_RESULT_CODES resultCode)
        {
            try
            {
                if (resultCode == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
                {
                    /*byte[] data;
                     * WebSocketClient.WEBSOCKET_PACKET_TYPES opCode;
                     *
                     * _client.Receive(out data, out opCode);
                     *
                     * var sData = Encoding.ASCII.GetString(data, 0, data.Length);
                     *
                     * ReceiveDataEventArgs e = new ReceiveDataEventArgs();
                     * e.ID = ID;
                     * e.Data = sData;
                     *
                     * OnReceiveDataChange(e);
                     *
                     * if (onDataReceived != null)
                     * {
                     *  onDataReceived(sData);
                     * }*/
                }

                return(1);
            }
            catch (SocketException se)
            {
                if (debugMode)
                {
                    ErrorLog.Exception(string.Format("WebSocketCleint ID {0} SocketException Occured in ClientSendCallBack", ID), se);
                }

                return(0);
            }
            catch (Exception e)
            {
                if (debugMode)
                {
                    ErrorLog.Exception(string.Format("WebSocketCleint ID {0} Exception Occured in ClientSendCallBack", ID), e);
                }

                return(0);
            }
        }
Exemplo n.º 20
0
        public int ReceiveCallback(byte[] data, uint datalen, WebSocketClient.WEBSOCKET_PACKET_TYPES opcode, WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                string receiveBuffer = Encoding.UTF8.GetString(data, 0, data.Length);
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket ReceiveCallback receiveBuffer: " + receiveBuffer);
                }

                if (receiveBuffer.Contains("webSocketClientKeepAlive"))
                {
                    keepAliveMessageReceived = true;
                    sendDataAsync("webSocketClientKeepAlive");
                }

                else if (receiveBuffer.Contains("webSocketClientDisconnect"))
                {
                    //Prepare keepAlive check routine to disconnect
                    //We can't just call disconnect here because ReceiveCallback must return a value before the socket can disconnect.
                    keepAliveMessageReceived = false;
                    keepAliveCounter         = 2;
                }

                else
                {
                    dataReceiveEvent(receiveBuffer);
                }

                resultCodes = wsc.ReceiveAsync();
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket ReceiveAsync resultCodes: " + resultCodes.ToString());
                }
            }
            catch (Exception e)
            {
                if (debug > 0)
                {
                    CrestronConsole.Print("\n Websocket ReceiveCallback exception: " + e.Message);
                }
                return(-1);
            }
            return(0);
        }
        /// <summary>
        /// Connect to the Pushbullet Websocket to monitor for Pushes
        /// </summary>
        public void connect()
        {
            wsc.URL       = "wss://stream.pushbullet.com/websocket/" + Access_Token;
            wrc           = wsc.Connect();
            wsc.KeepAlive = true;

            if (wsc.Connected)
            //if (wrc == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
            {
                CrestronConsole.PrintLine("Websocket connected \r\n");
                getUserInfo();
            }
            else
            {
                CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + wrc.ToString());
            }
            //UpdateDevice(Sender_Iden, "MyProcessor", "CP3", "Crestron");
        }
Exemplo n.º 22
0
 /// <summary>
 /// Connect to the Pushbullet Websocket to monitor for Pushes
 /// </summary>
 public static void connect()
 {
     wsc.Port            = 443;
     wsc.SSL             = true;
     wsc.SendCallBack    = SendCallback;
     wsc.ReceiveCallBack = ReceiveCallback;
     SendData            = System.Text.Encoding.ASCII.GetBytes(DataToSend);
     wsc.URL             = "wss://stream.pushbullet.com/websocket/" + Access_Code;
     wrc = wsc.Connect();
     if (wrc == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
     {
         CrestronConsole.PrintLine("Websocket connected \r\n");
     }
     else
     {
         CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + wrc.ToString());
     }
 }
        public int ReceiveCallback(
            byte[] data,
            uint datalen,
            WebSocketClient.WEBSOCKET_PACKET_TYPES opcode,
            WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__CLOSE)
                {
                    // Pass "true" as callback to ensure the callback
                    // will report disconnected instead of success
                    _socket.DisconnectAsync(true);
                    return((int)error);
                }

                string dataReceived         = Encoding.Default.GetString(data, 0, (int)datalen);
                DataEventArgs <string> args = new DataEventArgs <string>(dataReceived);
                DataReceived.Invoke(this, args);

                Log(string.Format("RX: {0}", dataReceived));


                // Handle reconnect
                if (error != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_ALREADY_CONNECTED ||
                    error != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_PENDING ||
                    error != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
                {
                    ConnectClient();
                }
            }
            catch (Exception e)
            {
                if (EnableLogging)
                {
                    Log(string.Format("WebSocketTransport : Receive Callback Exception: {0}", e.Message));
                }
            }
            finally
            {
                _socket.ReceiveAsync();
            }
            return((int)error);
        }
Exemplo n.º 24
0
 public int DisconnectCallBack(WebSocketClient.WEBSOCKET_RESULT_CODES error, object obj)
 {
     try
     {
         if (debug > 0)
         {
             CrestronConsole.Print("\n Websocket DisconnectCallBack error: " + error.ToString());
         }
     }
     catch (Exception e)
     {
         if (debug > 0)
         {
             CrestronConsole.Print("\n Websocket DisconnectCallBack exception: " + e.Message);
         }
         return(-1);
     }
     return(0);
 }
Exemplo n.º 25
0
        public int connect()
        {
            try
            {
                ret = ws_client.Connect();
                if (ret == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
                {
                    CrestronConsole.Print("[WSClient.connect] websocket connected");
                }
                else
                {
                    CrestronConsole.PrintLine("[WSClient.connect] websocket could not connect, err: {0}" + ret.ToString());
                }
            }
            catch (Exception ex) {
                CrestronConsole.PrintLine("[WSClient.connect] exception : {0}", ex.ToString());
            }

            return((int)ret);
        }
        private int ConnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            UpdateConnectionStatus(error, "ConnectCallback");
            if (!Connected)
            {
                if (EnableLogging)
                {
                    Log(string.Format("WebSocketTransport : Unable to connect - {0}", error));
                }

                // Handle reconnect
                if (error != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_ALREADY_CONNECTED ||
                    error != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_PENDING ||
                    error != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
                {
                    ConnectClient();
                }
            }

            return((int)error);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Connect to the Pushbullet Websocket to monitor for Pushes
        /// </summary>
        public void connect()
        {
            PBSocket.URL       = "wss://stream.pushbullet.com/websocket/" + DeviceToken;
            PBSocketResultCode = PBSocket.Connect();
            PBSocket.KeepAlive = true;

            if (PBSocket.Connected)
            {
                CrestronConsole.PrintLine("Websocket connected \r\n");
                PushConnected(1);
            }
            else
            {
                CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + PBSocketResultCode.ToString());
                PushConnected(0);
            }
            getUserInfo();

            //UpdateDevice();
            //UpdateDevice(Sender_Iden, "MyProcessor", "CP3", "Crestron");
        }
Exemplo n.º 28
0
        //Connect Method for establishing the WebSocket Connection
        public void Connect()
        {
            MyWSConnection.Port = 443;
            MyWSConnection.SSL  = true;
            MyWSConnection.URL  = "wss://stream.pushbullet.com/websocket/" + User_Token;
            MyWSConnection.ConnectionCallBack = SendCallback;
            MyWSConnection.ReceiveCallBack    = ReceiveCallback;

            MyWSConnectionResult = MyWSConnection.Connect();

            if (MyWSConnectionResult == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
            {
                PrintString = "Connection Success!";

                PrintString2 = "This is the msg: " + MyWSConnection.ReceiveAsync();
            }
            else
            {
                PrintString = "Cannot Establish Web Socket Connection. Err Code:" + MyWSConnectionResult.ToString();
            }
        }
Exemplo n.º 29
0
        public int ReceiveCallback(byte[] data, uint datalen,
                                   WebSocketClient.WEBSOCKET_PACKET_TYPES opcode,
                                   WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                string data_rcv = Encoding.UTF8.GetString(data, 0, data.Length);
                CrestronConsole.PrintLine("[WSClient.ReceiveCallback] data rcv: {0}", data_rcv);

                if (data_rcv.Trim() != "")
                {
                    JObject obj      = JObject.Parse(data_rcv);
                    int     msg_type = int.Parse(obj["msg_type"].ToString());
                    string  dt       = obj["dt"].ToString();
                    switch (msg_type)
                    {
                    case (int)CommonUtil.MSG_TYPE.MSG_PONG:
                        CrestronConsole.PrintLine("[WSClient.ReceiveCallback] rcv PONG");
                        ping_count = 0;
                        break;

                    case (int)CommonUtil.MSG_TYPE.MSG_LIGHT_SWITCH_ONOFF:
                        CrestronConsole.PrintLine("[WSClient.ReceiveCallback] rcv SWITCH ON/OFF");
                        switch_on_off(dt);
                        break;

                    case (int)CommonUtil.MSG_TYPE.MSG_LIGHT_CHANGE_BRIGHTNESS:
                        change_brightness(dt);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex) {
                CrestronConsole.PrintLine("[WSClient.ReceiveCallback] exception : {0}", ex.ToString());
            }
            return(0);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        int Websocket_ConnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code)
        {
            if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
            {
                StopServerReconnectTimer();
                Debug.Console(1, this, "Websocket connected");
                WSClient.DisconnectCallBack = Websocket_DisconnectCallback;
                WSClient.SendCallBack       = Websocket_SendCallback;
                WSClient.ReceiveCallBack    = Websocket_ReceiveCallback;
                WSClient.ReceiveAsync();
                SendMessageObjectToServer(new
                {
                    type = "hello"
                });
            }
            else
            {
                if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_HTTP_HANDSHAKE_TOKEN_ERROR)
                {
                    // This is the case when app server is running behind a websever and app server is down
                    Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed. Check that app server is running behind web server");
                }
                else if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SOCKET_CONNECTION_FAILED)
                {
                    // this will be the case when webserver is unreachable
                    Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed");
                }
                else
                {
                    Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failure: {0}", code);
                }
                StartServerReconnectTimer();
            }

            return(0);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Connect to the Pushbullet Websocket to monitor for Pushes
 /// </summary>
 public void connect()
 {
     wsc.URL = "wss://stream.pushbullet.com/websocket/" + Access_Code;
     wrc = wsc.Connect();
     
     if (wrc == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
     {
         CrestronConsole.PrintLine("Websocket connected \r\n");
     }
     else
     {
         CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + wrc.ToString());
     }
     getUserInfo();
 }
Exemplo n.º 32
0
 /// <summary>
 /// Connect to the Pushbullet Websocket to monitor for Pushes
 /// </summary>
 public static void connect()
 {
     wsc.Port = 443;
     wsc.SSL = true;
     wsc.SendCallBack = SendCallback;
     wsc.ReceiveCallBack = ReceiveCallback;
     SendData = System.Text.Encoding.ASCII.GetBytes(DataToSend);
     wsc.URL = "wss://stream.pushbullet.com/websocket/" + Access_Code;
     wrc = wsc.Connect();
     if (wrc == (int)WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
     {
         CrestronConsole.PrintLine("Websocket connected \r\n");
     }
     else
     {
         CrestronConsole.Print("Websocket could not connect to server.  Connect return code: " + wrc.ToString());
     }
 }
Exemplo n.º 33
0
        /// <summary>
        /// The Following Three Methods are for the Websocket
        /// </summary>
        /// <param name="error"></param>
        /// <returns></returns>
        public static int SendCallback(WebSocketClient.WEBSOCKET_RESULT_CODES error)
        {
            try
            {
                ret = wsc.ReceiveAsync();
            }
            catch (Exception e)
            {
                return -1;
            }

            return 0;
        }