Example #1
0
        public static void Main()
        {
            _client = new XSocketClient("127.0.0.1", 4502, "JsonProtocol", "Welcome to JsonProtocol");

            _client.OnOpen += (sender, args) =>
            {
                Debug.Print("Connected");
                // Tell the server that I am a Netduino
                _client.SetEnum("Hardware", "Netduino", "Sensor");

                //Start sending fake sensor data
                sensorThread = new Thread(Sensor);
                sensorThread.Start();
            };
            _client.OnClose += (sender, args) =>
            {
                Debug.Print("Closed");
                sensorThread.Suspend();
            };
            //Listen for messages
            _client.OnMessage += _client_OnMessage;

            //Open connection
            _client.Open();

            //Prevent exit since that would stop the program
            Thread.Sleep(Timeout.Infinite);
        }
Example #2
0
        /// <summary>
        /// Conneciton open, send hardware type and listen for button pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private static void ConnOnOpen(object sender, EventArgs eventArgs)
        {
            //Initialize IoT Controller and set the ClientType
            _conn.SetEnum("ClientType", "Netduino", "IoT");

            Button.OnInterrupt += button_OnInterrupt;
        }
Example #3
0
        public static void Main()
        {
            _client = new XSocketClient("127.0.0.1", 4502, "JsonProtocol", "Welcome to JsonProtocol");

            _client.OnOpen += (sender, args) =>
            {
                Debug.Print("Connected");
                // Tell the server that I am a Netduino
                _client.SetEnum("Hardware","Netduino","Sensor");
                
                //Start sending fake sensor data
                sensorThread = new Thread(Sensor);
                sensorThread.Start();
            };
            _client.OnClose += (sender, args) =>
            {
                Debug.Print("Closed");
                sensorThread.Suspend();
            };
            //Listen for messages
            _client.OnMessage += _client_OnMessage;

            //Open connection
            _client.Open();            

            //Prevent exit since that would stop the program
            Thread.Sleep(Timeout.Infinite);
        }