56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Chat.Framework.WXSdk.IPAD
|
|
{
|
|
/// <summary>
|
|
/// 协议微信 Host
|
|
/// </summary>
|
|
public class WechatHost
|
|
{
|
|
public List<string> LongServerList { get; set; }
|
|
public List<string> ShortServerList { get; set; }
|
|
|
|
public string GetSort()
|
|
{
|
|
if (ShortServerList.Count == 0) return "short.weixin.qq.com";
|
|
var list = Util.GetRandomList<string>(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<string>();
|
|
ShortServerList = new List<string>();
|
|
}
|
|
|
|
public string GetLong()
|
|
{
|
|
if (LongServerList == null || LongServerList.Count == 0) return "long.weixin.qq.com";
|
|
|
|
var list = Util.GetRandomList<string>(LongServerList);
|
|
foreach (var item in list)
|
|
{
|
|
var ip = Util.Ping(item);
|
|
if (ip)
|
|
{
|
|
return item;
|
|
}
|
|
}
|
|
return list[0];
|
|
}
|
|
}
|
|
}
|