You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
846 B
31 lines
846 B
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using AX.NetworkSystem;
|
||
|
using AX.Network.Protocols;
|
||
|
using System;
|
||
|
using System.Net;
|
||
|
|
||
|
public class GET_GATEWAY_REPLY : NetworkMessageBehaviour
|
||
|
{
|
||
|
public struct ServerInfo
|
||
|
{
|
||
|
public int GroupType;//1表示登陆服务器,2表示网关,4表示文件服务器
|
||
|
public string IPAddress;
|
||
|
public short Port;
|
||
|
}
|
||
|
|
||
|
protected override void Execute(BinaryMessage message)
|
||
|
{
|
||
|
var info = message.Body.Deserialize<ServerInfo[]>();
|
||
|
|
||
|
int index = UnityEngine.Random.Range(0, info.Length);
|
||
|
|
||
|
if (info[index].GroupType == 2)
|
||
|
{
|
||
|
NetworkManager.DestroySession(NetworkManager.Default);
|
||
|
NetworkManager.CreateDefaultSession(info[index].IPAddress, info[index].Port);
|
||
|
NetworkManager.Default.Start();
|
||
|
}
|
||
|
}
|
||
|
}
|