/// <summary> /// LS通知CS有客户端登录成功 /// </summary> public ErrorCode OnLs2CsGclogin(NetSessionBase session, Google.Protobuf.IMessage message) { Protos.LS2CS_GCLogin gcLogin = (Protos.LS2CS_GCLogin)message; CSUser user = CS.instance.userMgr.CreateUser(gcLogin); Protos.CS2LS_GCLoginRet gcLoginRet = ProtoCreator.R_LS2CS_GCLogin(gcLogin.Opts.Pid); gcLoginRet.Result = user != null ? Protos.CS2LS_GCLoginRet.Types.EResult.Success : Protos.CS2LS_GCLoginRet.Types.EResult.Failed; session.Send(gcLoginRet); return(ErrorCode.Success); }
private static void OnGCLoginCSRet(NetSessionBase session, Google.Protobuf.IMessage message, object[] args) { Protos.LS2GC_AskLoginRet gcLoginRet = (Protos.LS2GC_AskLoginRet)args[0]; uint sid = ( uint )args[1]; ulong gcNID = ( ulong )args[2]; Protos.CS2LS_GCLoginRet csLoginRet = (Protos.CS2LS_GCLoginRet)message; if (csLoginRet.Result == Protos.CS2LS_GCLoginRet.Types.EResult.Success) { gcLoginRet.Result = Protos.LS2GC_AskLoginRet.Types.EResult.Success; gcLoginRet.SessionID = gcNID; foreach (KeyValuePair <uint, GSInfo> kv in LS.instance.gsInfos) { GSInfo info = kv.Value; Protos.GSInfo gsInfo = new Protos.GSInfo { Name = info.name, Ip = info.ip, Port = info.port, Password = info.password, State = (Protos.GSInfo.Types.State)info.state }; gcLoginRet.GsInfos.Add(gsInfo); } Logger.Log($"client:{gcNID} login success"); //通知客户端登陆结果 LS.instance.netSessionMgr.Send(sid, gcLoginRet); LS.instance.netSessionMgr.CloseSession(sid, "login complete"); } else { Logger.Log($"client:{gcNID} login failed"); gcLoginRet.Result = Protos.LS2GC_AskLoginRet.Types.EResult.Failed; //通知客户端登陆结果 LS.instance.netSessionMgr.Send(sid, gcLoginRet); LS.instance.netSessionMgr.CloseSession(sid, "login failed"); } }