Ejemplo n.º 1
0
 public MessageStreamImpl(StreamMsgConsumeFactory msgConsumeFactory,
                          HttpResponse response, ITopCometMessageListener msgListener, TopCometStreamImpl cometStreamImpl)
     : base(msgConsumeFactory, response)
 {
     this.msgListener     = msgListener;
     this.objLock         = cometStreamImpl.GetControlLock();
     this.cometStreamImpl = cometStreamImpl;
 }
Ejemplo n.º 2
0
 public MessageStreamImpl(StreamMsgConsumeFactory msgConsumeFactory,
     HttpResponse response, ITopCometMessageListener msgListener, TopCometStreamImpl cometStreamImpl)
     : base(msgConsumeFactory, response)
 {
     this.msgListener = msgListener;
     this.objLock = cometStreamImpl.GetControlLock();
     this.cometStreamImpl = cometStreamImpl;
 }
Ejemplo n.º 3
0
 public MessageStreamImpl(StreamMsgConsumeFactory msgConsumeFactory, HttpResponse response, ITopCometMessageListener msgListener, TopCometStreamImpl cometStreamImpl) : base(msgConsumeFactory, response)
 {
     this.logger = new DefaultTopLogger();
     this.pattern = "\\{\"packet\":\\{\"code\":(?<code>(\\d+))(,\"msg\":(?<msg>((.+))))?\\}\\}";
     this.objLock = new object();
     this.msgListener = msgListener;
     this.objLock = cometStreamImpl.GetControlLock();
     this.cometStreamImpl = cometStreamImpl;
 }
Ejemplo n.º 4
0
 public void SetMessageListener(ITopCometMessageListener cometMessageListener)
 {
     this.cometMessageListener = cometMessageListener;
 }
Ejemplo n.º 5
0
 public void SetMessageListener(ITopCometMessageListener cometMessageListener)
 {
     this.cometMessageListener = cometMessageListener;
 }
 public MockTopCometMessageListener(MessageDriver driver, ITopCometMessageListener topCometMessageListener)
 {
     this.driver = driver;
     this.topCometMessageListener = topCometMessageListener;
 }
 public void setCometMessageListener(ITopCometMessageListener topCometMessageListener)
 {
     this.topCometMessageListener = topCometMessageListener;
     MessageHandler handler = new MessageHandler(this.topCometMessageListener);
     driver.messageHandler = handler;
 }
 public MessageHandler(ITopCometMessageListener topCometMessageListener)
 {
     this._topCometMessageListener = topCometMessageListener;
 }
Ejemplo n.º 9
0
 public void SetMsgListener(ITopCometMessageListener msgListener)
 {
     this.msgListener = msgListener;
 }
Ejemplo n.º 10
0
 public void SetMsgListener(ITopCometMessageListener msgListener)
 {
     this.msgListener = msgListener;
 }
Ejemplo n.º 11
0
        public void Start()
        {
            //原以为设置了cometRequst的msgListenr,就没有必要在本地msgListener未设置时抛出异常
            //我把检测放在后面,当cometRequst的msglistener和本地msglistener都找不到时才抛出异常
            //后来发现本地cometMessageListener必须赋值,从cometRequst中获取

            List<TopCometStreamRequest> cometRequests = conf.GetConnectReqParam();

            msgConsumeFactory = new StreamMsgConsumeFactory(conf.GetMinThreads(), conf.GetMaxThreads(), conf.GetQueueSize());

            for (int i = 0; i < cometRequests.Count; i++)
            {
                try
                {
                    TopCometStreamRequest cometRequest = cometRequests[i];
                    if (cometRequest.GetConnectListener() == null)
                    {
                        cometRequest.SetConnectListener(connectionListener);
                    }
                    if (cometMessageListener == null)
                    {
                        if (cometRequest.GetMsgListener() == null)
                            throw new Exception("Comet message listener must not null");
                        else
                            cometMessageListener = cometRequest.GetMsgListener();
                        //cometRequest.SetMsgListener(cometMessageListener);
                    }
                    Thread controlThread = new Thread(delegate()
                    {
                        ControlThread(msgConsumeFactory, ref bstop, conf, cometRequest);
                    });
                    controlThread.Name = "stream-control-thread-connectid-" + cometRequest.GetConnectId();
                    controlThread.Start();
                    controlThreads.Add(controlThread);
                }
                catch
                {
                    continue;
                }
            }
        }