/// <summary> /// 将主机添加到指定分组 /// </summary> /// <param name="group">要添加到的分组的名字</param> public void addGroup(string group) { Peer peer = Peer.find(id); if (this.groups == null) { this.groups = new List <string>(); } if (peer != null) { peer.addInto(group); } HostGroup.add(this, group); groups.Add(group); }
/// <summary> /// 刷新分组 /// </summary> /// <param name="groups">新的分组</param> public void rGroup(string[] groups) { Peer peer = Peer.find(id); if (groups == null) { groups = new string[0]; } if (this.groups == null) { this.groups = new List <string>(); } for (int i = 0; i < this.groups.Count; i++) { if (!groups.Contains(this.groups[i])) { if (peer != null) { peer.quitFrom(this.groups[i]); } HostGroup.remove(this, this.groups[i]); this.groups.RemoveAt(i--); } } for (int i = 0; i < groups.Length; i++) { if (!this.groups.Contains(groups[i])) { if (peer != null) { peer.addInto(groups[i]); } HostGroup.add(this, groups[i]); this.groups.Add(groups[i]); } } }