Пример #1
0
        /// <summary>
        /// Get a list of newly discovered sensors.
        /// </summary>
        /// <returns>A list of sensors.</returns>
        public SearchResult GetNewSensors()
        {
            SearchResult newSensors = new SearchResult();

            CommResult comres = Communication.SendRequest(new Uri(BridgeUrl + "/lights/new"), WebRequestType.GET);

            switch (comres.status)
            {
            case WebExceptionStatus.Success:
                newSensors = Serializer.DeserializeSearchResult(comres.data);
                if (newSensors != null)
                {
                    return(newSensors);
                }
                newSensors = new SearchResult();
                List <Message> lstmsg = Serializer.DeserializeToObject <List <Message> >(Communication.lastjson);
                lastMessages = lstmsg != null ? new MessageCollection(lstmsg) : new MessageCollection {
                    new UnkownError(comres)
                };
                break;

            case WebExceptionStatus.Timeout:
                lastMessages = new MessageCollection {
                    _bridgeNotResponding
                };
                BridgeNotResponding?.Invoke(this, _e);
                break;

            default:
                lastMessages = new MessageCollection {
                    new UnkownError(comres)
                };
                break;
            }


            return(newSensors);
        }