static void Main(string[] args) { MsgConsumer consumer = new MsgConsumer(); consumer.Consume((msg) => { Console.WriteLine("接收到消息:" + msg); return(msg == "2018"); }); // 如果监听Second消息队列 需要注释上行 //consumer.Consume((msg) => //{ // Console.WriteLine("接收到消息2:" + msg); // return msg == "2018"; //}, "Second"); }
public override void init(MsgConsumer consumer) { for (int i = 0; i < serverCount;i++ ) { udpServers[i] = new UDPServer(local[i], this); } for (int i=0; i< clientCount;i++) { udpClients[i] = new UDPClient(remote[i]); } if (clientCount > 1) { deliveryThreads = new SplitThread[clientCount]; for (int i=0; i < clientCount; i++) { deliveryThreads[i] = new SplitThread(i, udpClients[i], msgID); } } base.init(consumer); }
public virtual void init(MsgConsumer consumer) { this.consumer = consumer; }
/// <summary> /// Register consumers. /// </summary> /// <param name="item"></param> public void addConsumer(MsgConsumer item) { consumers.Add(item); }
public DispatchMsgService(MsgConsumer[] target) { if (target == null || target.Length == 0) { throw new ArgumentNullException("target"); } this.target = target; }
public BasicMsgService(MsgConsumer target) { this.target = target; }