/// <summary> /// 构造器 /// </summary> /// <param name="key">参数</param> public StatRequest(StatItems key = StatItems.nothing) { if (key != StatItems.nothing) { this.Key = Encoding.ASCII.GetBytes(key.ToString()); } }
public Statistic(StatCategory category, StatItems item, VarInt value = null !) { if (value == null !) { value = 0; } Category = (int)category; Id = (int)item; Value = value; }
/// <summary> /// 获取服务器状态信息 /// </summary> /// <param name="item">选项</param> /// <exception cref="SocketException"></exception> /// <returns></returns> public List <KeyValuePair <string, string> > Stat(StatItems item = StatItems.nothing) { return(this.Request <List <KeyValuePair <string, string> > >(client => { var dic = new List <KeyValuePair <string, string> >(); var responses = client.Sends(new StatRequest(item)); foreach (var res in responses) { if (res.TotalBody > 0) { var k = Encoding.ASCII.GetString(res.Key); var v = Encoding.ASCII.GetString(res.Value); dic.Add(new KeyValuePair <string, string>(k, v)); } } return dic; })); }
/// <summary> /// 获取服务器状态信息 /// </summary> /// <param name="ip">服务器IP</param> /// <param name="item">选项</param> /// <exception cref="SocketException"></exception> /// <returns></returns> public List <KeyValuePair <string, string> > Stat(IPEndPoint ip, StatItems item = StatItems.nothing) { return(this.memCacheds.FirstOrDefault(m => m.IPEndPoint == ip).Stat(item)); }