Example #1
0
        public static void Init()
        {
            Console.WriteLine("Please enter applicaiton details");
            Console.Write("Enter your org id :");
            orgId = Console.ReadLine();

            Console.Write("Enter your app id :");
            appId = Console.ReadLine();

            Console.Write("Enter your api Key :");
            apiKey = Console.ReadLine();

            Console.Write("Enter your auth token :");
            authToken = Console.ReadLine();

            Console.WriteLine("Please enter device details to which you want to implement Infomation Mangement");

            Console.Write("Enter your device type :");
            deviceType = Console.ReadLine();

            Console.Write("Enter your device id :");
            deviceID = Console.ReadLine();

            Console.Write("Enter your device event :");
            deviceEvent = Console.ReadLine();

            client = new ApplicationClient(orgId, appId, apiKey, authToken);
            client.connect();
            cli         = client.GetAPIClient();
            cli.Timeout = 30000;
            //MQTT Topic subscription for IM State
            client.subscribeToIMState(deviceType, deviceID);
            client.IMStateCallback += processIM;
        }
Example #2
0
        public void  ApplicationClientSubscribeToIMState()
        {
            testApp.subscribeToIMState();
            string typeId   = "";
            string deviceId = "";
            string LIId     = "";
            string json     = "";

            testApp.IMStateCallback += (dt, did, liid, data) => {
                typeId   = dt;
                deviceId = did;
                LIId     = liid;
                json     = data;
            };
            string msg = "name:foo,cpu:60,mem:50";
            MqttMsgPublishEventArgs evt = new MqttMsgPublishEventArgs("iot-2/type/demotest/id/1qaz2wsx/intf/59a6c41052faff002c332a3b/evt/state", System.Text.Encoding.UTF8.GetBytes(msg), false, 1, true);

            testApp.client_MqttMsgArrived(new {}, evt);
            Assert.AreEqual("demotest", typeId);
            Assert.AreEqual("1qaz2wsx", deviceId);
            Assert.AreEqual("59a6c41052faff002c332a3b", LIId);
            Assert.AreEqual(msg, json);
        }