public int OnNotifyServerAddr(LSToGC.ServerBSAddr pMsg) { SelectServerData.Instance.Clean(); for (int i = 0; i < pMsg.serverinfo.Count; i++) { string addr = pMsg.serverinfo[i].ServerAddr; int state = pMsg.serverinfo[i].ServerState; string serverName = pMsg.serverinfo[i].ServerName; string[] sArray = serverName.Split('/'); string name = sArray[0]; string area = sArray[1]; int port = pMsg.serverinfo[i].ServerPort; //添加到服务器列表中 SelectServerData.Instance.SetServerList(i, name, (SelectServerData.ServerState)state, addr, port, area); } EventCenter.Broadcast((Int32)GameEventEnum.UserEvent_NotifyServerAddr); return((int)ErrorCodeEnum.Normal); }
//更新服务器列表 public void UpdateServerAddr(Stream stream) { LSToGC.ServerBSAddr pMsg = ProtoBuf.Serializer.Deserialize <LSToGC.ServerBSAddr>(stream); SelectServerData.Instance.Clean(); for (int i = 0; i < pMsg.serverinfo.Count; i++) { string addr = pMsg.serverinfo.ElementAt(i).ServerAddr; int state = pMsg.serverinfo.ElementAt(i).ServerState; string name = pMsg.serverinfo.ElementAt(i).ServerName; int port = pMsg.serverinfo.ElementAt(i).ServerPort; SelectServerData.Instance.SetServerList(i, name, (SelectServerData.ServerState)state, addr, port); } NetworkManager.Instance.Close(); NetworkManager.Instance.canReconnect = false; SelectServerData.Instance.SetDefaultServer(); EventCenter.Broadcast(EGameEvent.eGameEvent_SdkServerCheckSuccess); }