internal void OnCreate(Protos.LS2CS_GCLogin gcLogin, long loginTime) { this.channel = (CSUserMgr.Channel)gcLogin.Channel; this.browser = (CSUserMgr.Browser)gcLogin.Browser; this.platform = (CSUserMgr.Platform)gcLogin.Platform; this.ukey = gcLogin.Ukey; this.gcNID = gcLogin.GcNID; this.openID = gcLogin.Id; this.sessionKey = gcLogin.SessionKey; this.unionID = gcLogin.UnionID; this.loginTime = loginTime; this.nickname = gcLogin.Nickname; this.avatar = gcLogin.Avatar; this.gender = ( byte )gcLogin.Gender; this.money = gcLogin.Money; this.diamoned = gcLogin.Diamoned; this.rank = gcLogin.Rank; this.exp = gcLogin.Exp; string[] pairs = gcLogin.Champions.Split('|'); int count = pairs.Length; for (int i = 0; i < count; i++) { string pair = pairs[i]; this.champions.Add(pair == string.Empty ? -1 : int.Parse(pair)); } this.actorID = gcLogin.ActorID; }
private static void HandleLoginSuccess(Protos.LS2GC_AskLoginRet gcLoginRet, uint sid, LoginContext context) { ulong gcNID = GuidHash.GetUInt64(); //通知cs,客户端登陆成功 Protos.LS2CS_GCLogin csLogin = ProtoCreator.Q_LS2CS_GCLogin(); csLogin.GcNID = gcNID; csLogin.Id = context.id; csLogin.Ukey = context.ukey; csLogin.Channel = context.channel; csLogin.Browser = context.browser; csLogin.Platform = context.platform; csLogin.SessionKey = context.sessionKey; csLogin.UnionID = context.unionID; csLogin.Nickname = context.nickname; csLogin.Avatar = context.avatar; csLogin.Gender = context.gender; csLogin.Money = context.money; csLogin.Diamoned = context.diamoned; csLogin.Rank = context.rank; csLogin.Exp = context.exp; csLogin.Champions = context.champions; csLogin.ActorID = context.actorID; LS.instance.netSessionMgr.Send(SessionType.ServerL2CS, csLogin, RPCEntry.Pop(OnGCLoginCSRet, gcLoginRet, sid, gcNID)); }
/// <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); }
/// <summary> /// 创建玩家登陆凭证 /// </summary> internal CSUser CreateUser(Protos.LS2CS_GCLogin gcLogin) { CSUser user = this.GetUser(gcLogin.Ukey); if (user == null) { user = new CSUser(); this._ukeyToUser[gcLogin.Ukey] = user; this._authUsers.Add(user); } else { //处理顶号 if (user.isConnected) { this.KickUser(user, ( int )Protos.CS2GS_KickGC.Types.EReason.DuplicateLogin); } this._gcNIDToUser.Remove(user.gcNID); } user.OnCreate(gcLogin, TimeUtils.utcTime); this._gcNIDToUser[gcLogin.GcNID] = user; Logger.Info($"user:{user.gcNID} was created"); return(user); }