Наследование: ISubscription, IDisposable
Пример #1
0
 /// <summary>
 /// Creates an empty message.
 /// </summary>
 public Msg()
 {
     subject = null;
     reply   = null;
     data    = null;
     sub     = null;
 }
Пример #2
0
        internal Msg(MsgArg arg, Subscription s, byte[] payload, long length)
        {
            this.subject = arg.subject;
            this.reply   = arg.reply;
            this.sub     = s;

            // make a deep copy of the bytes for this message.
            this.data = new byte[length];
            Array.Copy(payload, this.data, length);
        }
Пример #3
0
        // when our base (Connection) removes a subscriber, clean up
        // our references to the encoded handler wrapper.
        internal override void removeSub(Subscription s)
        {
            // The subscription may not be present - request reply uses
            // a sync subscription which won't be added to the wrappers.
            if (wrappers.ContainsKey(s))
            {
                wrappers.Remove(s);
            }

            base.removeSub(s);
        }
Пример #4
0
        // unsubscribe performs the low level unsubscribe to the server.
        // Use Subscription.Unsubscribe()
        internal void unsubscribe(Subscription sub, int max)
        {
            lock (mu)
            {
                if (isClosed())
                    throw new NATSConnectionClosedException();

                Subscription s = subs[sub.sid];
                if (s == null)
                {
                    // already unsubscribed
                    return;
                }

                if (max > 0)
                {
                    s.max = max;
                }
                else
                {
                    removeSub(s);
                }

                // We will send all subscriptions when reconnecting
                // so that we can supress here.
                if (!isReconnecting())
                    writeString(IC.unsubProto, s.sid, max);

            }

            kickFlusher();
        }
Пример #5
0
        internal void removeSub(Subscription s)
        {
            Subscription o;

            subs.TryRemove(s.sid, out o);
            if (s.mch != null)
            {
                s.mch.close();
                s.mch = null;
            }

            s.conn = null;
        }
Пример #6
0
 private void addSubscription(Subscription s)
 {
     s.sid = Interlocked.Increment(ref ssid);
     subs[s.sid] = s;
 }
Пример #7
0
 // processSlowConsumer will set SlowConsumer state and fire the
 // async error handler if registered.
 void processSlowConsumer(Subscription s)
 {
     if (opts.AsyncErrorEventHandler != null && !s.sc)
     {
         new Task(() =>
         {
             opts.AsyncErrorEventHandler(this,
                 new ErrEventArgs(this, s, "Slow Consumer"));
         }).Start();
     }
     s.sc = true;
 }
Пример #8
0
 internal ErrEventArgs(Connection c, Subscription s, String err)
 {
     this.c = c;
     this.s = s;
     this.err = err;
 }
Пример #9
0
        internal virtual void removeSub(Subscription s)
        {
            Subscription o;

            subs.TryRemove(s.sid, out o);
            if (s.mch != null)
            {
                if (s.ownsChannel)
                    s.mch.close();

                s.mch = null;
            }

            s.conn = null;
            s.closed = true;
        }
Пример #10
0
 // processSlowConsumer will set SlowConsumer state and fire the
 // async error handler if registered.
 internal void processSlowConsumer(Subscription s)
 {
     lastEx = new NATSSlowConsumerException();
     if (opts.AsyncErrorEventHandler != null && !s.sc)
     {
         EventHandler<ErrEventArgs> aseh = opts.AsyncErrorEventHandler;
         callbackScheduler.Add(
             new Task(() => { aseh(this, new ErrEventArgs(this, s, "Slow Consumer")); })
         );
     }
     s.sc = true;
 }