/// <summary> /// 将主机从指定分组中删除 /// </summary> /// <param name="group">要从中删除的分组的名字</param> public void removeGroup(string group) { Peer peer = Peer.find(id); if (this.groups == null) { this.groups = new List <string>(); } if (peer != null) { peer.quitFrom(group); } HostGroup.remove(this, group); groups.Remove(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]); } } }