Example #1
0
        IEnumerator CreateUserEnumerator(
            string applicationName,
            string deviceName,
            Action <string> generatedUserName,
            Action <List <HueErrorInfo> > errorCallback = null
            )
        {
            var body = new Dictionary <string, object>()
            {
                { HueKeys.DEVICE_TYPE, string.Format("{0}#{1}", applicationName, deviceName) }
            };

            var www = new WWWWrapper(BaseURL, body);

            yield return(www.waitToFinish());

            if (isValidJsonResponse(www, errorCallback))
            {
                JSON response = www.responseJSON.getJsonArray("rootArray")[0].getJSON("success");
                var  userName = response.getString(HueKeys.USER_NAME, "");
                if (userName != "")
                {
                    generatedUserName(userName);
                }
            }
        }
Example #2
0
        IEnumerator DeleteEnumerator(string url, Action <List <HueErrorInfo> > errorCallback = null)
        {
            var www = new WWWWrapper(url, method: HTTPMethod.DELETE);

            yield return(www.waitToFinish());

            isValidJsonResponse(www, errorCallback);                    // Just check for errors.
        }
Example #3
0
        IEnumerator SendRequestEnumerator(WWWWrapper www, Action <string> successCallback,
                                          Action <List <HueErrorInfo> > errorCallback = null)
        {
            yield return(www.waitToFinish());

            if (isValidJsonResponse(www, errorCallback) && successCallback != null)
            {
                successCallback(www.responseText);
            }
        }
Example #4
0
        IEnumerator GetBridgesEnumerator(Action <List <HueBridgeInfo> > bridgesCallback, Action <List <HueErrorInfo> > errorCallback = null)
        {
            var www = new WWWWrapper(hueDiscoveryServer);

            yield return(www.waitToFinish());

            if (isValidJsonResponse(www, errorCallback))
            {
                ProcessBridges(www.responseJSON, bridgesCallback);
            }
        }
Example #5
0
        IEnumerator DiscoverGroupsEnumerator(Action <List <HueGroup> > groupsCallback, Action <List <HueErrorInfo> > errorCallback)
        {
            string url = string.Format("{0}/{1}/groups", BaseURL, currentBridge.userName);

            var www = new WWWWrapper(url);

            yield return(www.waitToFinish());

            if (isValidJsonResponse(www, errorCallback))
            {
                ProcessGroups(www.responseJSON, groupsCallback);
            }
        }
Example #6
0
        IEnumerator UpdateLightFromBridgeEnumerator(string id, HueLight lightToUpdate, Action <List <HueErrorInfo> > errorCallback = null)
        {
            string url = string.Format("{0}/lights/{1}", BaseURLWithUserName, id);

            var www = new WWWWrapper(url);

            yield return(www.waitToFinish());

            if (isValidJsonResponse(www, errorCallback))
            {
                ProcessLightUpdate(www.responseJSON, lightToUpdate);
            }
        }