public ServerInfo(ServerJsonData data) { this.serverId = data.id.ToInt32(); this.host = data.ip; this.port = data.port.ToInt32(); this.name = data.name; this.state = (ServerState)data.status.ToInt32(); this.isInnerNet = false; }
private IEnumerator GetServersStatusCoroutine() { long timeStamp = Common.Util.TimeUtil.GetTimeStampBefore10(); string sign = Common.Util.EncryptUtil.String2MD5("get_areastatus" + timeStamp + Logic.Game.GameConfig.getServerListKey); int platformId = PlatformProxy.instance.GetPlatformId(); string platform = "0"; if (platformId != 0) { platform = platformId.ToString(); } string finalUrl = string.Format(Logic.Game.GameConfig.GetServerListUrl() + "?cmdid=get_areastatus&time={0}&sign={1}&platformId={2}", timeStamp, sign.ToLower(), platform); Debugger.Log("finalUrl:" + finalUrl); WWW www = new WWW(finalUrl); yield return(www); if (www.error != null) { Debugger.LogError("-----------------从服务端获得的服务器列表 有误"); getServerList = false; } else { _serverListDictionary.Clear(); try { JsonData data = JsonMapper.ToObject(www.text); int count = data.Count; for (int i = 0; i < count; i++) { ServerJsonData d = JsonMapper.ToObject <ServerJsonData>(data[i].ToJson()); _serverListDictionary.Add(d.id.ToInt32(), new ServerInfo(d)); } if (_serverListDictionary.Count < 0) { Debugger.LogError("从服务端获得的服务器列表为空,当前渠道号:" + platformId); getServerList = false; } else { if (getServerListFromRemoteSucDelegate != null) { getServerListFromRemoteSucDelegate(); } } } catch (System.Exception e) { Debugger.LogError("从服务端获得的服务器列表错误,msg:" + e.StackTrace); getServerList = false; } } }