Esempio n. 1
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            string lname = Guid.NewGuid().ToString();

            client = new MQTT.Client.Client(new MqttNetworkBroker(new MQTT.Domain.NetworkInterface(new CommandReader(), new CommandWriter())));

            client.ClientId = lname;

            client.OnUnsolicitedMessage += new UnsolicitedMessageCallback(c_OnUnsolicitedMessage);

            DnsLookup(server, port);

            while (ipEndpoint == null)
            {
                Thread.Sleep(50);
            }

            client.Connect(ipEndpoint);

            client.Subscribe(
                new Subscription[]
            {
                new Subscription(topic, QualityOfService.ExactlyOnce),
            }, null);
        }
Esempio n. 2
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            string lname = Guid.NewGuid().ToString();

            client = new MQTT.Client.Client(new MqttNetworkBroker(new MQTT.Domain.NetworkInterface(new CommandReader(), new CommandWriter())));

            client.ClientId = lname;

            client.OnUnsolicitedMessage += new UnsolicitedMessageCallback(c_OnUnsolicitedMessage);

            DnsLookup(server, port);

            while (ipEndpoint == null)
            {
                Thread.Sleep(50);
            }

            client.Connect(ipEndpoint);

            client.Subscribe(
                new Subscription[]
                    {
                        new Subscription(topic, QualityOfService.ExactlyOnce),
                    }, null);
        }
Esempio n. 3
0
 protected override void OnDoubleTap(GestureEventArgs e)
 {
     if (client.IsConnected)
     {
         client.Disconnect(TimeSpan.FromSeconds(1));
     }
     else
     {
         client.Connect(ipEndpoint);
         client.Subscribe(
             new Subscription[]
         {
             new Subscription(topic, QualityOfService.ExactlyOnce),
         }, null);
     }
 }