コード例 #1
0
ファイル: HubController.cs プロジェクト: nunanas21/CIS-109
 public async Task <bool> Connect()
 {
     try
     {
         msgHub.Connect();
         msgHub.ReceiveCloudToDeviceMessageAsync(DateTime.UtcNow);
         return(true);
     } catch (System.Exception e)
     {
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        /// Attempt to create a deviceclient/instance of AzureIoTHub with credentials given.
        /// If instantiation fails, then the login page will be shown, with an error message
        /// </summary>
        /// <returns>the page to load</returns>
        private async Task <string> LoginWithCredentials(string host, string device, string shared)
        {
            string html             = "";
            string connectionString = DeviceConnectionStringBuilder.CreateWithDeviceInfo(host, device, shared);

            if (msgHub.Connect(connectionString))
            {
                html = await LoadPage(NavConstants.DEFAULT_PAGE);

                string loc = await lp.GetLocation();

                devloc = "Device Location: " + loc;
                html   = await LoadandUpdateStatus("Device Location: #location#", devloc, NavConstants.DEFAULT_PAGE);

                originalPages[NavConstants.DEFAULT_PAGE] = html;
            }
            else
            {
                html = await LoadandUpdateStatus(loginStatus, Constants.LOGIN_ERROR, NavConstants.LOGIN);

                loginStatus = Constants.LOGIN_ERROR;
            }
            return(html);
        }