Esempio n. 1
0
 /// <summary>
 /// 初始化
 /// </summary>
 public static void Init()
 {
     BaseDispatch.BindEventHandler(OnPlayerXY, EProtocolId.E2G_GAME_PLAYERXY);
     BaseDispatch.BindEventHandler(OnLogin, EProtocolId.L2E_GAME_LOGINSERVER);
     BaseDispatch.BindEventHandler(OnRegister, EProtocolId.L2E_GAME_REGISTER);
     BaseDispatch.BindEventHandler(OnLoginOut, EProtocolId.E2G_GAME_LOGINOUT);
     //BaseDispatch.BindEventHandler(OnPlayerMapIn, EProtocolId.E2G_GAME_MAPIN);
 }
Esempio n. 2
0
        public static void OnBasePing(LunarSession session, LunarRequestInfo requestInfo)
        {
            var Rsp = new All_Base_Ping()
            {
                ServerTime = DateTime.Now,
            };

            BaseDispatch.Send(session, Rsp);
        }
Esempio n. 3
0
 /// <summary>
 /// 新连接事件
 /// </summary>
 /// <param name="session"></param>
 public static void OnSessionConnected(LunarSession session)
 {
     loger.Debug("接收到连接: " + session.SessionID);
     BaseServerInfo.AllSessions.TryAdd(session.SessionID, session);
     BaseDispatch.Send(session, new S2C_Server_Connect()
     {
         ServerID = BaseServerInfo.ServerID
     });
 }
        //发送给游戏服务器消息
        public static void SendToGame(int serverID, INbsSerializer objMsg)
        {
            var nbs = objMsg.Serialize();

            if (DictServerLinkGame.TryGetValue(serverID, out var serverlink))
            {
                var session = BaseServerInfo.AppServer.GetSessionByID(serverlink.SessionID);
                BaseDispatch.Send(session, objMsg);
            }
        }
        //广播给游戏服务器消息
        public static void BoardcastToGame(INbsSerializer objMsg)
        {
            var nbs = objMsg.Serialize();

            foreach (var item in DictServerLinkGame.Values)
            {
                var session = BaseServerInfo.AppServer.GetSessionByID(item.SessionID);
                BaseDispatch.Send(session, objMsg);
            }
        }
 public static void SendMsg(INbsSerializer msg, List <long> puids)
 {
     foreach (var puid in puids)
     {
         if (Dispatcher.DictPuidSession.TryGetValue(puid.ToString(), out var session))
         {
             //session.Send(msg);
             BaseDispatch.Send(session, msg);
         }
     }
 }
Esempio n. 7
0
        internal static void OnLogin(LunarSession session, LunarRequestInfo requestInfo)
        {
            var Req = new E2L_Game_LoginServer(requestInfo.Body);
            var Rsp = new L2E_Game_LoginServer();

            Rsp.Shuttle = Req.Shuttle;
            if (!DataCache.TryGetValue(Req.Account, out var user))
            {
                Rsp.Result = EProtocolResult.账号不存在;
                BaseDispatch.Send(session, Rsp); return;
            }
            if (Req.Password != user.Password)
            {
                Rsp.Result = EProtocolResult.密码错误; BaseDispatch.Send(session, Rsp); return;
            }
            Rsp.Puid = user.Uuid;
            BaseDispatch.Send(session, Rsp);
        }
Esempio n. 8
0
        internal static void OnRegister(LunarSession session, LunarRequestInfo requestInfo)
        {
            var Req = new E2L_Game_Register(requestInfo.Body);
            var Rsp = new L2E_Game_Register();

            Rsp.Shuttle = Req.Shuttle;
            if (DataCache.TryGetValue(Req.Account, out var user))
            {
                Rsp.Result = EProtocolResult.账号已存在;
                BaseDispatch.Send(session, Rsp); return;
            }

            Rsp.Puid = CreateUuid();

            user          = new User();
            user.Uuid     = Rsp.Puid;
            user.Account  = Req.Account;
            user.Password = Req.Password;

            DataCache[Req.Account] = user;
            user.Save();
            BaseDispatch.Send(session, Rsp);
        }
Esempio n. 9
0
 public static void Init()
 {
     BaseDispatch.BindEventHandler(OnBasePing, EProtocolId.ALL_BASE_PING);
     BaseDispatch.BindEventHandler(OnLogin, EProtocolId.E2L_GAME_LOGINSERVER);
     BaseDispatch.BindEventHandler(OnRegister, EProtocolId.E2L_GAME_REGISTER);
 }
Esempio n. 10
0
 // 心跳循环内容
 public static void HeartbeatExecute()
 {
     //消息分发
     BaseDispatch.Heartbeat();
     PlayerManager.Heartbeat();
 }
Esempio n. 11
0
 public static void Init()
 {
     BaseDispatch.BindEventHandler(OnServerInfo, EProtocolId.G2D_GAME_SERVER);
 }
Esempio n. 12
0
 // 心跳循环内容
 public static void HeartbeatExecute()
 {
     //消息分发
     BaseDispatch.Heartbeat();
 }
Esempio n. 13
0
 public static void Init()
 {
     BaseDispatch.BindEventHandler(OnBasePing, EProtocolId.ALL_BASE_PING);
     BaseDispatch.BindEventHandler(OnBaseServer, EProtocolId.S2C_SERVER_CONNECT);
 }