コード例 #1
0
    public List <string> GetDeviceActions(string deviceName)
    {
        apiWarning = GameObject.FindObjectOfType <WarningApiText>();
        List <string> deviceActions = new List <string>();

        try
        {
            apiWarning.HideWarning();

            HttpWebRequest request =
                (HttpWebRequest)WebRequest.Create($"{_smartDeviceApiUrl}/GetAvailableActionsOfSingleTypeSmartDevice/?type={deviceName}");

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader    reader   = new StreamReader(response.GetResponseStream());

            string jsonResponse = "{\"Items\":" + reader.ReadToEnd() + "}";
            deviceActions = JsonHelper.FromJson <string>(jsonResponse).ToList();
        }
        catch (System.Exception)
        {
            apiWarning.ShowWarning();
        }

        return(deviceActions);
    }
コード例 #2
0
    public string GetDeviceState(string id)
    {
        apiWarning = GameObject.FindObjectOfType <WarningApiText>();
        string deviceState = string.Empty;

        try
        {
            apiWarning.HideWarning();

            HttpWebRequest request =
                (HttpWebRequest)WebRequest.Create($"{_smartDeviceApiUrl}/GetStateOfSingleSmartDevice/?id={id}");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader    reader   = new StreamReader(response.GetResponseStream());

            deviceState = reader.ReadToEnd();
        }
        catch (System.Exception)
        {
            apiWarning.ShowWarning();
        }

        return(deviceState.Replace("\"", ""));
    }
コード例 #3
0
    public string GetDeviceTypeById(string id)
    {
        apiWarning = GameObject.FindObjectOfType <WarningApiText>();
        string deviceType = string.Empty;

        try
        {
            apiWarning.HideWarning();

            HttpWebRequest request =
                (HttpWebRequest)WebRequest.Create($"{_smartDeviceApiUrl}/GetSingleSmartDevice/?id={id}");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader    reader   = new StreamReader(response.GetResponseStream());

            deviceType = JsonUtility.FromJson <DeviceModel>(reader.ReadToEnd()).Type;
        }
        catch (System.Exception)
        {
            apiWarning.ShowWarning();
        }

        return(deviceType);
    }