using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chat.Framework.WXSdk.IPAD { /// /// 协议微信 Host /// public class WechatHost { public List LongServerList { get; set; } public List ShortServerList { get; set; } public string GetSort() { if (ShortServerList.Count == 0) return "short.weixin.qq.com"; var list = Util.GetRandomList(ShortServerList); foreach (var item in list) { return item; } throw new Exception("您的网络可能有问题,无法连接网络!"); } public void BindLongip(string ip) { LongServerList.Clear(); LongServerList.Add(ip); } public WechatHost() { LongServerList = new List(); ShortServerList = new List(); } public string GetLong() { if (LongServerList == null || LongServerList.Count == 0) return "long.weixin.qq.com"; var list = Util.GetRandomList(LongServerList); foreach (var item in list) { var ip = Util.Ping(item); if (ip) { return item; } } return list[0]; } } }