示例#1
0
        public async Task Subscribe(string service, string eventName, object credentials = null)
        {
            if (!Ws.IsConnected)
            {
                throw new Exception("ws is not connected");
            }

            var subRequest = new HubRequest
            {
                service     = service,
                eventName   = eventName,
                credentials = credentials,
                method      = "subscribe"
            };

            if (_subscriptions.Contains(subRequest))
            {
                _subscriptions.Remove(subRequest);
            }

            await _restProtocol.RequestAsync(subRequest);

            _subscriptions.Add(subRequest);
            if (EventSubscribed != null)
            {
                EventSubscribed(this, new EventArgs <HubRequest>(subRequest));
            }
        }
示例#2
0
 public Task RequestAsync(RestRequest req, int timeout = 0)
 {
     return(_restProtocol.RequestAsync(req, timeout));
 }