From 0f6039b521975ddaf6ce74246d7fdf978b07d987 Mon Sep 17 00:00:00 2001 From: bob <605277374@qq.com> Date: Sat, 26 Jul 2025 17:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Startup/Init.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/Startup/Init.cs b/Assets/Scripts/Startup/Init.cs index 6a7d57101..5c0ed8245 100644 --- a/Assets/Scripts/Startup/Init.cs +++ b/Assets/Scripts/Startup/Init.cs @@ -5,9 +5,7 @@ using Assets.Scripts.Hotfix; using FairyGUI; using NBC; using NBC.Network; -using NBC.Platform.Unity; using UnityEngine; -using UnityEngine.Audio; using UnityEngine.Video; namespace NBF @@ -152,21 +150,14 @@ namespace NBF private async FTask OnLoginButtonClick() { // NBC.Platform.Unity.Entry.Initialize(GetType().Assembly); - + // 根据用户名来选择目标的鉴权服务器 // 根据鉴权服务器地址来创建一个新的网络会话 _session = SessionHelper.CreateSession(App.Main, "127.0.0.1:20001", OnConnectComplete, OnConnectFail, OnConnectDisconnect); - var acc = "test001"; - - // // 发送一个注册的请求消息到目标服务器 - // var responseReg = (A2C_RegisterResponse)await _session.Call(new C2A_RegisterRequest() - // { - // Username = acc, - // Password = acc - // }); + var acc = "test003"; // 发送登录的请求给服务器 var response = (A2C_LoginResponse)await _session.Call(new C2A_LoginRequest() @@ -175,7 +166,7 @@ namespace NBF Password = acc, LoginType = 1 }); - + if (response.ErrorCode != 0) { Log.Error($"登录发生错误{response.ErrorCode}"); @@ -203,6 +194,11 @@ namespace NBF Log.Debug( $"登录到Gate服务器成功!LoginTime:{loginResponse.GameAccountInfo.LoginTime} CreateTime:{loginResponse.GameAccountInfo.CreateTime}"); + + var getResponse = (G2C_GetAccountInfoResponse)await _session.Call(new C2G_GetAccountInfoRequest()); + var gameAcc = getResponse.GameAccountInfo; + Log.Info($"gameAcc LoginTime:{gameAcc.LoginTime} CreateTime:{gameAcc.CreateTime}"); + // getResponse.GameAccountInfo.LoginTime.ToString() } private void OnConnectComplete() @@ -210,7 +206,7 @@ namespace NBF Log.Debug("连接成功"); // 添加心跳组件给Session。 // Start(2000)就是2000毫秒。 - _session.AddComponent().Start(2000); + _session.AddComponent().Start(5000); } private void OnConnectFail()