Пример #1
0
        protected JsonRPCFuture(string objectId, string method)
        {
            id = FutureId.Next();

            if (string.IsNullOrEmpty(objectId))
            {
                this.method = method;
                return;
            }

            if (objectId.EndsWith("/"))
            {
                this.method = objectId + method;
            }
            else
            {
                this.method = objectId + "/" + method;
            }
        }
Пример #2
0
        Task <IPremiseSubscription> IPremiseObject.SubscribeAsync(string propertyName, string alexaController, Action <dynamic> callback)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentException(nameof(propertyName));
            }

            string clientSideSubscriptionId = FutureId.Next().ToString();

            Subscription subscription = new Subscription(clientSideSubscriptionId)
            {
                sysObjectId         = _objectId,
                propertyName        = propertyName,
                alexaControllerName = alexaController,
                callback            = callback
            };

            _client.AddSubscription(clientSideSubscriptionId, subscription);

            var future = new SubscribeFuture(_objectId, propertyName, clientSideSubscriptionId);

            _client.Send(future, clientSideSubscriptionId, out Task <IPremiseSubscription> task);
            return(task);
        }