public MainPage()
        {
            this.InitializeComponent();
            _relayClient = new RelayNodeClient();

            _timer = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromSeconds(3);
            _timer.Tick += _timer_Tick;
            _timer.Start();
        }
        private async Task SendCompletionMessageForOnOff(RelayNodeClient client, string target, bool turnItOn)
        {
            var userMessage = new VoiceCommandUserMessage();

            if (!client.IsReady)
            {
                string noController = string.Format(
                                       cortanaResourceMap.GetValue("noControllerFound", cortanaContext).ValueAsString,
                                       target);
                userMessage.DisplayMessage = noController;
                userMessage.SpokenMessage = noController;
            }
            else
            {
                int relayId = 0;
                switch (target)
                {
                    default:
                    case "light":
                    case "lamp":
                        relayId = 0;
                        break;
                    case "fan":
                        relayId = 1;
                        break;
                }

                if (turnItOn)
                {
                    client.SetRelay(relayId, true);
                    string turnedOn = string.Format(
                                           cortanaResourceMap.GetValue("turnedOnMessage", cortanaContext).ValueAsString,
                                           target);
                    userMessage.DisplayMessage = turnedOn;
                    userMessage.SpokenMessage = turnedOn;
                }
                else
                {
                    client.SetRelay(relayId, false);
                    string turnedOn = string.Format(
                                           cortanaResourceMap.GetValue("turnedOffMessage", cortanaContext).ValueAsString,
                                           target);
                    userMessage.DisplayMessage = turnedOn;
                    userMessage.SpokenMessage = turnedOn;
                }
            }

            //var response = VoiceCommandResponse.CreateResponse(userMessage, destinationsContentTiles);
            var response = VoiceCommandResponse.CreateResponse(userMessage);
            await voiceServiceConnection.ReportSuccessAsync(response);
        }
        private async Task<RelayNodeClient> GetClient()
        {
            if (_client==null)
            {
                _client = new RelayNodeClient();
            }
            int iRetries = 20;
            while (!_client.IsReady)
            {
                await Task.Delay(250);
                if (--iRetries == 0)
                    break;
            }

            return _client;
        }