|
@@ -28,6 +28,33 @@ namespace ET
|
|
return ErrorCode.ERR_Success;
|
|
return ErrorCode.ERR_Success;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static async ETTask<int> LoginTest(Scene zoneScene, string address, string account)
|
|
|
|
+ {
|
|
|
|
+ A2C_LoginAccount a2CLoginAccount = null;
|
|
|
|
+ Session accountSession = null;
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ accountSession = zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(address));
|
|
|
|
+
|
|
|
|
+ a2CLoginAccount = (A2C_LoginAccount)await accountSession.Call(new C2A_LoginTest() { Account = account });
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ accountSession?.Dispose();
|
|
|
|
+ Log.Error(e.ToString());
|
|
|
|
+ return ErrorCode.ERR_NetWorkError;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (a2CLoginAccount.Error != ErrorCode.ERR_Success)
|
|
|
|
+ {
|
|
|
|
+ accountSession?.Dispose();
|
|
|
|
+ return a2CLoginAccount.Error;
|
|
|
|
+ }
|
|
|
|
+ OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession);
|
|
|
|
+
|
|
|
|
+ return ErrorCode.ERR_Success;
|
|
|
|
+ }
|
|
|
|
+
|
|
public static async ETTask<int> Login(Scene zoneScene, string address, string account, string password, bool isMD5)
|
|
public static async ETTask<int> Login(Scene zoneScene, string address, string account, string password, bool isMD5)
|
|
{
|
|
{
|
|
A2C_LoginAccount a2CLoginAccount = null;
|
|
A2C_LoginAccount a2CLoginAccount = null;
|
|
@@ -55,18 +82,24 @@ namespace ET
|
|
accountSession?.Dispose();
|
|
accountSession?.Dispose();
|
|
return a2CLoginAccount.Error;
|
|
return a2CLoginAccount.Error;
|
|
}
|
|
}
|
|
|
|
+ OnLoginSuccess(zoneScene, a2CLoginAccount, accountSession);
|
|
|
|
+
|
|
|
|
+ return ErrorCode.ERR_Success;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void OnLoginSuccess(Scene zoneScene, A2C_LoginAccount a2CLoginAccount, Session accountSession)
|
|
|
|
+ {
|
|
if (zoneScene.GetComponent<SessionComponent>() == null)
|
|
if (zoneScene.GetComponent<SessionComponent>() == null)
|
|
{
|
|
{
|
|
zoneScene.AddComponent<SessionComponent>();
|
|
zoneScene.AddComponent<SessionComponent>();
|
|
}
|
|
}
|
|
zoneScene.GetComponent<SessionComponent>().Session = accountSession;
|
|
zoneScene.GetComponent<SessionComponent>().Session = accountSession;
|
|
- zoneScene.GetComponent<SessionComponent>().Session.AddComponent<PingComponent>();
|
|
|
|
|
|
+ accountSession.AddComponent<PingComponent>();
|
|
|
|
+ accountSession.AddComponent<DisConnectedCompnent>();
|
|
AccountInfoComponent accountInfoComponent = zoneScene.GetComponent<AccountInfoComponent>();
|
|
AccountInfoComponent accountInfoComponent = zoneScene.GetComponent<AccountInfoComponent>();
|
|
accountInfoComponent.Token = a2CLoginAccount.Token;
|
|
accountInfoComponent.Token = a2CLoginAccount.Token;
|
|
accountInfoComponent.AccountId = a2CLoginAccount.AccountId;
|
|
accountInfoComponent.AccountId = a2CLoginAccount.AccountId;
|
|
accountInfoComponent.Age = a2CLoginAccount.Age;
|
|
accountInfoComponent.Age = a2CLoginAccount.Age;
|
|
-
|
|
|
|
- return ErrorCode.ERR_Success;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public static async ETTask<int> Register(Scene zoneScene, string address, string account, string password, string name, string identityNum, string code)
|
|
public static async ETTask<int> Register(Scene zoneScene, string address, string account, string password, string name, string identityNum, string code)
|
|
@@ -118,7 +151,7 @@ namespace ET
|
|
{
|
|
{
|
|
return a2C_GetServerInfos.Error;
|
|
return a2C_GetServerInfos.Error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ zoneScene.GetComponent<ServerInfosComponent>()?.ServerInfoList?.Clear();
|
|
foreach (var serverInfoProto in a2C_GetServerInfos.ServerInfosList)
|
|
foreach (var serverInfoProto in a2C_GetServerInfos.ServerInfosList)
|
|
{
|
|
{
|
|
ServerInfo serverInfo = zoneScene.GetComponent<ServerInfosComponent>().AddChild<ServerInfo>();
|
|
ServerInfo serverInfo = zoneScene.GetComponent<ServerInfosComponent>().AddChild<ServerInfo>();
|
|
@@ -259,7 +292,7 @@ namespace ET
|
|
|
|
|
|
zoneScene.GetComponent<AccountInfoComponent>().RealmKey = a2C_GetRealmKey.RealmKey;
|
|
zoneScene.GetComponent<AccountInfoComponent>().RealmKey = a2C_GetRealmKey.RealmKey;
|
|
zoneScene.GetComponent<AccountInfoComponent>().RealmAddress = a2C_GetRealmKey.RealmAddress;
|
|
zoneScene.GetComponent<AccountInfoComponent>().RealmAddress = a2C_GetRealmKey.RealmAddress;
|
|
- zoneScene.GetComponent<SessionComponent>().Session.Dispose();
|
|
|
|
|
|
+ zoneScene.GetComponent<SessionComponent>().Disconnect();
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
await ETTask.CompletedTask;
|
|
return ErrorCode.ERR_Success;
|
|
return ErrorCode.ERR_Success;
|