Example #1
0
 public Subscription(IWampTopic topic, WampObserver observer, IDisposable disposable)
 {
     mTopic      = topic;
     mObserver   = observer;
     mDisposable = disposable;
     TrackConnection();
 }
Example #2
0
        private void RaiseSubscriptionAdded(WampObserver observer)
        {
            EventHandler <WampSubscriptionAddEventArgs> added =
                SubscriptionAdded;

            if (added != null)
            {
                added(this, new WampSubscriptionAddEventArgs(observer.SessionId,
                                                             observer));
            }
        }
Example #3
0
        public IDisposable Subscribe(IObserver <object> observer)
        {
            WampObserver casted = observer as WampObserver;

            IDisposable result;

            if (casted == null)
            {
                IObservable <object> events = mSubject.Select(x => x.Event);

                result =
                    events.Subscribe(observer);

                result = GetSubscriptionDisposable(result);
            }
            else
            {
                RaiseSubscriptionAdding(casted);

                string sessionId = casted.SessionId;

                IObservable <object> relevantMessages =
                    mSubject.Where(x => ShouldPublishMessage(x, sessionId))
                    .Select(x => x.Event);

                IDisposable observerDisposable =
                    relevantMessages.Subscribe(observer);

                result =
                    new CompositeDisposable
                        (Disposable.Create(() => OnWampObserverLeaving(sessionId)),
                        observerDisposable,
                        Disposable.Create(() => OnWampObserverLeft(sessionId)));

                result =
                    GetSubscriptionDisposable(result);

                mSessionIdToSubscription[sessionId] =
                    new Subscription(this, casted, result);

                RaiseSubscriptionAdded(casted);
            }

            return(result);
        }
Example #4
0
 protected bool Equals(WampObserver other)
 {
     return(string.Equals(mTopicUri, other.mTopicUri) &&
            Equals(Client, other.Client));
 }