Program(string appkey) { Console.WriteLine("Initialize the client with the appkey: " + appkey + "\n"); try { // Instantiate client using MqttClientFactory with appkey _client = MqttClientFactory.CreateClientWithAppkey(appkey); } catch (Exception) { Console.WriteLine("Instantiate the client failed. Please check your network and app key, then try it again."); Environment.Exit(0); } // Enable auto reconnect _client.AutoReconnect = true; // Setup some useful client delegate callbacks _client.Connected += new ConnectionDelegate(client_Connected); _client.ConnectionLost += new ConnectionDelegate(_client_ConnectionLost); _client.PublishArrived += new PublishArrivedDelegate(client_PublishArrived); _client.Published += new CompleteDelegate(_client_Published); _client.Subscribed += new CompleteDelegate(_client_Subscribed); _client.Unsubscribed += new CompleteDelegate(_client_Unsubscribed); }