Example #1
0
        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");
        }
Example #2
0
 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);
 }
Example #3
0
 public virtual void init(MsgConsumer consumer)
 {
     this.consumer = consumer;
 }
Example #4
0
 /// <summary>
 /// Register consumers.
 /// </summary>
 /// <param name="item"></param>
 public void addConsumer(MsgConsumer item)
 {
     consumers.Add(item);
 }
Example #5
0
 public DispatchMsgService(MsgConsumer[] target)
 {
     if (target == null || target.Length == 0)
     {
         throw new ArgumentNullException("target");
     }
     this.target = target;
 }
Example #6
0
 public BasicMsgService(MsgConsumer target)
 {
     this.target = target;
 }