private IStanSubscription subscribe(string subject, string qgroup, EventHandler <StanMsgHandlerArgs> handler, StanSubscriptionOptions options) { AsyncSubscription sub = new AsyncSubscription(this, options); lock (mu) { if (nc == null) { throw new StanConnectionClosedException(); } // Register the subscription subMap[sub.Inbox] = sub; IConnection localNc = nc; } try { sub.subscribe(subRequests, subject, qgroup, handler); } catch { lock (mu) { subMap.Remove(sub.Inbox); } throw; } return(sub); }
internal void processMsg(object sender, MsgHandlerEventArgs args) { bool isClosed = false; AsyncSubscription sub = null; Msg raw = null; MsgProto mp = new MsgProto(); ProtocolSerializer.unmarshal(args.Message.Data, mp); raw = args.Message; lock (mu) { isClosed = (nc == null); subMap.TryGetValue(raw.Subject, out sub); } if (isClosed || sub == null) { return; } sub.processMsg(mp); }
internal StanMsg(MsgProto p, AsyncSubscription s) { proto = p; sub = s; }