Ejemplo n.º 1
0
        static void Instance_ListenerAcceptMessage(object sender, MessageListenerEventArgs e)
        {
            ChangeConsoleOut();

#if (PrivateUse)
            string ip = e.Listener.FromIP;
            if (ip.StartsWith("192.168.") || ip.StartsWith("127.0.0.1")) //测试,仅限于局域网使用
            {
                ip = string.Empty;
            }
            else
            {
                Console.WriteLine("错误,{0}", UseDescrition);
                return;
            }
#endif
            //下面整个处理过程应该放到一个动态实例对象的方法中,否则,多线程问题难以避免
            SubscriberInfo   subInfo   = new SubscriberInfo(e.Listener);
            MessageProcesser processer = new MessageProcesser(subInfo, e.Listener.FromMessage);
            processer.ServiceErrorEvent += new EventHandler <ServiceErrorEventArgs>(Processer_ServiceErrorEvent);
            //Console.WriteLine("process message begin.");
            try
            {
                processer.Process();
            }
            catch (Exception ex)
            {
                Processer_ServiceErrorEvent(processer, new ServiceErrorEventArgs(ex));
            }
            //Console.WriteLine("process message end.");
        }
Ejemplo n.º 2
0
        static void Instance_ListenerRequestMessage(object sender, MessageRequestEventArgs e)
        {
            MessageProcesser processer = new MessageProcesser();

            try
            {
                processer.Execute(e);
            }
            catch (Exception ex)
            {
                Processer_ServiceErrorEvent(processer, new ServiceErrorEventArgs(ex));
            }
        }
Ejemplo n.º 3
0
        static void Instance_ListenerRequestMessage(object sender, MessageRequestEventArgs e)
        {
            MessageProcesser processer = new MessageProcesser();

            processer.Execute(e);
        }