Inheritance: ISubscription, IDisposable
Exemplo n.º 1
0
 /// <summary>
 /// Creates an empty message.
 /// </summary>
 public Msg()
 {
     subject = null;
     reply   = null;
     data    = null;
     sub     = null;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
        }
Exemplo n.º 6
0
 private void addSubscription(Subscription s)
 {
     s.sid = Interlocked.Increment(ref ssid);
     subs[s.sid] = s;
 }
Exemplo n.º 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;
 }
Exemplo n.º 8
0
 internal ErrEventArgs(Connection c, Subscription s, String err)
 {
     this.c = c;
     this.s = s;
     this.err = err;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
 }