|
@@ -6,18 +6,19 @@ namespace ET.Client
|
|
|
{
|
|
|
public static class LoginHelper
|
|
|
{
|
|
|
- public static async ETTask<int> Login(string ip, int port)
|
|
|
+ public static async ETTask<int> Login(string ip, int port, int roomid)
|
|
|
{
|
|
|
- string account = "111";
|
|
|
- string password = "111";
|
|
|
Scene clientScene = ClientSceneManagerComponent.Instance.Get( 1 );
|
|
|
if( clientScene == null )
|
|
|
{
|
|
|
Log.Error( "Not found client scene" );
|
|
|
- return 0;
|
|
|
+ return ErrorCode.ERR_SystemError;
|
|
|
}
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
+ var strRoomid = roomid.ToString();
|
|
|
+
|
|
|
// 创建一个ETModel层的Session
|
|
|
clientScene.RemoveComponent<RouterAddressComponent>();
|
|
|
clientScene.RemoveComponent<NetClientComponent>();
|
|
@@ -30,13 +31,14 @@ namespace ET.Client
|
|
|
await routerAddressComponent.Init();
|
|
|
|
|
|
clientScene.AddComponent<NetClientComponent, AddressFamily>(routerAddressComponent.RouterManagerIPAddress.AddressFamily);
|
|
|
- IPEndPoint realmAddress = routerAddressComponent.GetRealmAddress(account);
|
|
|
+ //如果有多个网关地址,则通过roomid弄点花样模拟随机获取一个地址
|
|
|
+ IPEndPoint realmAddress = routerAddressComponent.GetRealmAddress( strRoomid );
|
|
|
|
|
|
// 登陆验证
|
|
|
R2C_Login r2CLogin;
|
|
|
using (Session session = await RouterHelper.CreateRouterSession(clientScene, realmAddress))
|
|
|
{
|
|
|
- r2CLogin = (R2C_Login)await session.Call(new C2R_Login() { RoomId = account });
|
|
|
+ r2CLogin = (R2C_Login)await session.Call(new C2R_Login() { RoomId = strRoomid } );
|
|
|
}
|
|
|
|
|
|
if (r2CLogin.Error != ErrorCode.ERR_Success)
|