Пример #1
0
        void ProcessBridges(JSON response, Action <List <HueBridgeInfo> > bridgesCallback)
        {
            Debug.LogFormat("Bridges: {0}", response);

            var list = new List <HueBridgeInfo>();

            var responseList = response.getJsonArray("rootArray");

            foreach (var item in responseList)
            {
                var bridgeInfo = new HueBridgeInfo(item.getString("id", ""), item.getString("internalipaddress", ""));

                if (item.hasKey("macaddress"))
                {
                    bridgeInfo.macAdress = item.getString("macaddress", "");
                }

                if (item.hasKey("name"))
                {
                    bridgeInfo.name = item.getString("name", "");
                }

                list.Add(bridgeInfo);
            }

            bridgesCallback(list);
        }
Пример #2
0
 public void RestoreHueState(StoredHueInfo savedState)
 {
     if (savedState == null)
     {
         return;
     }
     bridges       = savedState.allBridges;
     currentBridge = savedState.current;
 }
Пример #3
0
 public void DiscoverBridges(Action onFinished, Action <List <HueErrorInfo> > errorCallback)
 {
     StartCoroutine(GetBridgesEnumerator(
                        (bridges) =>
     {
         this.bridges = bridges;
         if (bridges.Count > 0)
         {
             currentBridge = bridges[0];
         }
         if (onFinished != null)
         {
             onFinished();
         }
     },
                        errorCallback
                        ));
 }
Пример #4
0
 public StoredHueInfo(HueBridgeInfo current, List <HueBridgeInfo> allBridges)
 {
     this.current    = current;
     this.allBridges = allBridges;
 }