Example #1
0
 protected override void Setup()
 {
     LBLogger.InitLogger(this.ApplicationRootPath, this.BinaryPath);
     RegisterPeerHandler();
     RegisterProtocolsSerialize();
     mHeartbeatFiber = new ThreadFiber();
     mHeartbeatFiber.ScheduleOnInterval(UpdateTick, 0, 1);
     mHeartbeatFiber.Start();
     mLastTick = TimeManager.Instance.CurrentTimeMs;
 }
Example #2
0
        public static void RegisterHandlerFunc(RqId requestId, System.Action <MyPeer, OperationRequest> invokeFunc)
        {
            byte rqIdByte = (byte)requestId;

            if (mPeerHandlerDic.ContainsKey(rqIdByte))
            {
                LBLogger.Error(LogTag, "注册重复的事件处理 " + requestId.ToString());
                return;
            }
            mPeerHandlerDic[rqIdByte] = invokeFunc;
        }
Example #3
0
 protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
 {
     System.Action <MyPeer, OperationRequest> invokeAction;
     if (mPeerHandlerDic.TryGetValue(operationRequest.OperationCode, out invokeAction))
     {
         LBLogger.Info(LogTag, "OnOperationRequest " + ((RqId)operationRequest.OperationCode).ToString());
         invokeAction.Invoke(this, operationRequest);
     }
     else
     {
         LBLogger.Error(LogTag, "消息处理没有注册 " + operationRequest.OperationCode);
     }
 }
Example #4
0
 protected override void TearDown()
 {
     LBLogger.Info("MyApplication", "游戏服务器关闭");
     mHeartbeatFiber.Dispose();
     mHeartbeatFiber = null;
 }
Example #5
0
 protected override void OnMessage(object message, SendParameters sendParameters)
 {
     LBLogger.Info(LogTag, "连接  OnMessage");
     base.OnMessage(message, sendParameters);
 }
Example #6
0
 protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
 {
     LBLogger.Info(LogTag, "连接  关闭 " + ConnectionId.ToString());
     LBPeerManager.Instance.RemovePeer(ConnectionId);
 }
Example #7
0
 public MyPeer(InitRequest initRequest) : base(initRequest)
 {
     LBLogger.Info(LogTag, "游戏服务器创建连接  " + ConnectionId.ToString());
     LBPeerManager.Instance.AddPeer(ConnectionId, this);
 }