/// <summary>注册消息消费者,仅消费指定通道的消息</summary> /// <param name="channel">通道</param> /// <returns>消息消费者</returns> public virtual IMessageConsumer Register(Byte channel) { if (channel <= 0 || channel >= 0x80) { throw new ArgumentOutOfRangeException("channel", "通道必须在0到128之间!"); } var mc = new MessageConsumer2(); mc.Channel = channel; mc.Provider = this; lock (Consumers2) { Consumers2.Add(mc); } mc.OnDisposed += (s, e) => { lock (Consumers2) { Consumers2.Remove(s as MessageConsumer2); } }; return(mc); }
/// <summary>注册消息消费者,仅消费指定通道的消息</summary> /// <param name="channel">通道</param> /// <returns>消息消费者</returns> public virtual IMessageConsumer Register(Byte channel) { if (channel <= 0 || channel >= 0x80) throw new ArgumentOutOfRangeException("channel", "通道必须在0到128之间!"); var mc = new MessageConsumer2(); mc.Channel = channel; mc.Provider = this; lock (Consumers2) { Consumers2.Add(mc); } mc.OnDisposed += (s, e) => { lock (Consumers2) { Consumers2.Remove(s as MessageConsumer2); } }; return mc; }