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