// 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); }
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); } }