public HeartBeatController(ControlTerminal server, long heartBeatTime = 10)
 {
     timer = new Timer(1000);
     this.controlTerminal = server;
     this.heartBeatTime   = heartBeatTime;
     timer.Elapsed       += new ElapsedEventHandler(HandleMainTimer);
     timer.AutoReset      = false;
     timer.Enabled        = true;
     Console.WriteLine("开启心跳包检查");
 }
Esempio n. 2
0
        private void Awake()
        {
            controlTerminal = new ControlTerminal();
            serverEventPool = new EventPool(MessageDistributionControl.Instance);
            serverEventPool.GetEvent <ExperimentRequestEvent>().AddReceiveEvent(OnExpReq);
            serverEventPool.GetEvent <ExperimentReceiptEvent>().AddReceiveEvent(OnExpRec);
            controlTerminal.Start("127.0.1", 8888);
            Thread thread = new Thread(OnUpdate);

            thread.Start();
        }
Esempio n. 3
0
        public ExperimentEventControl(ControlTerminal controlTerminal, Action <string> actionlog = null)
        {
            this.controlTerminal = controlTerminal;

            experimentInfo = new ExperimentInfo()
            {
                Id         = 0,
                OwnProject = string.Empty,
                Name       = string.Empty,
                IsBack     = false
            };

            this.actionLog = actionlog;

            //收到请求
            MessageDistributionControl.Instance.AddListener((int)CommandID.ExperimentInfoRequest, (int connectID, ProtobufTool data) =>
            {
                data.DeSerialize(experimentInfo, data.bytes);

                ProtobufTool tool = GetProtobuf(data, experimentInfo);

                controlTerminal.Broadcast(tool);

                if (actionLog != null)
                {
                    actionLog("ExperimentInfoRequest");
                }
            });

            MessageDistributionControl.Instance.AddListener((int)CommandID.ExperimentInfoReceipt, (int connectID, ProtobufTool data) =>
            {
                data.DeSerialize(experimentInfo, data.bytes);

                ProtobufTool tool = GetProtobuf(data, experimentInfo);

                controlTerminal.Broadcast(tool);

                if (actionLog != null)
                {
                    actionLog("发送请求,转发出去:ExperimentInfoReceipt");
                }
            });
        }