public virtual Task SubscribeAsync(IUnsubscribable item) { lock (_subscriptions) { if (_webSocket.State == WebSocketState.Closed) { return(item.OnUnsubscribeAsync(CancellationToken.None)); } if (_subscriptions.ContainsKey(item.CommandId)) { throw new InvalidOperationException("Item with id already subscribed"); } _subscriptions.Add(item.CommandId, item); } return(Task.CompletedTask); }
Task IWebSocketTunnel.SubscribeAsync(IUnsubscribable item) { return(_session.SubscribeAsync(item)); }