Пример #1
0
        public static void OnBasePing(LunarSession session, LunarRequestInfo requestInfo)
        {
            var Rsp = new All_Base_Ping()
            {
                ServerTime = DateTime.Now,
            };

            BaseDispatch.Send(session, Rsp);
        }
Пример #2
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);
            }
        }
Пример #5
0
 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);
         }
     }
 }
Пример #6
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);
        }
Пример #7
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);
        }