コード例 #1
0
 private void Subscribe(string name, Action<ITextArgs> callback, Action<ITextArgs> confirmCallback, SubscriptionType subscriptionType, uint limit = 0)
 {
     ThrowIfPrimitive();
     var subscription = new Subscription(name.ToLower(), callback, subscriptionType, limit, true);
     this.AddBinding(subscription);
     AddConfirmCallback(confirmCallback, subscription.Event);
     if (this.IsConnected)
     {
         Send(this.AsTextArgs(new XSubscriptions { Event = name.ToLower(), Confirm = true}, Constants.Events.PubSub.Subscribe), () => subscription.IsBound = true);
     }
 }
コード例 #2
0
 private void AddDefaultSubscriptions()
 {
     var onError = new Subscription(Constants.Events.OnError, Error) { IsBound = true };
     this.AddBinding(onError);
     var onOpen = new Subscription(Constants.Events.Connections.Opened, Opened) { IsBound = true };
     this.AddBinding(onOpen);
 }
コード例 #3
0
        private void Subscribe(string name, SubscriptionType subscriptionType, uint limit = 0)
        {
            ThrowIfPrimitive();
            var subscription = new Subscription(name, subscriptionType, limit);
            this.AddBinding(subscription);

            if (this.IsConnected)
            {
                Send(this.AsTextArgs(new XSubscriptions
                {
                    Event = name.ToLower()
                }, Constants.Events.PubSub.Subscribe), () => { subscription.IsBound = true; });
            }
        }
コード例 #4
0
        private void AddConfirmCallback(Action<ITextArgs> confirmCallback, string @event)
        {
            var e = string.Format("__{0}", @event);
            if (this.GetBindings().Any(p => p.Event == e)) return;

            var confirm = new Subscription(e, confirmCallback);
            this.AddBinding(confirm);
            confirm.IsBound = this.IsConnected;
        }