Example #1
0
        protected Task SubscribeAsync(RpcRequest rpcRequest)
        {
            if (SubscriptionState != SubscriptionState.Idle)
            {
                throw new Exception("Invalid state to start subscription, current state: " + SubscriptionState.ToString());
            }

            SubscribeRequestId = rpcRequest.Id;

            this.SubscriptionState = SubscriptionState.Subscribing;

            return(StreamingClient.SendRequestAsync(rpcRequest, this));
        }
Example #2
0
        public Task UnsubscribeAsync()
        {
            if (SubscriptionState != SubscriptionState.Subscribed && SubscriptionState != SubscriptionState.Unsubscribed) //allow retrying? what happens when it returns false the unsubscription
            {
                throw new Exception("Invalid state to unsubscribe, current state: " + SubscriptionState.ToString());
            }

            UnsubscribeRequestId = Guid.NewGuid().ToString();
            var request = UnsubscribeSubscriptionRpcRequestBuilder.BuildRequest(SubscriptionId, UnsubscribeRequestId);

            this.SubscriptionState = SubscriptionState.Unsubscribing;

            return(StreamingClient.SendRequestAsync(request, this));
        }