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