public static void OnBasePing(LunarSession session, LunarRequestInfo requestInfo) { var Rsp = new All_Base_Ping() { ServerTime = DateTime.Now, }; BaseDispatch.Send(session, Rsp); }
/// <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); } } }
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); }
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); }