protected virtual void HandleChangeGroupsOperation(LitePeer peer, ChangeGroups changeGroupsRequest, SendParameters sendParameters) { // get the actor who send the operation request Actor actor = this.GetActorByPeer(peer); if (actor == null) { return; } actor.RemoveGroups(changeGroupsRequest.Remove); if (changeGroupsRequest.Add != null) { if (changeGroupsRequest.Add.Length > 0) { foreach (var groupId in changeGroupsRequest.Add) { ActorGroup group; if (!this.actorGroups.TryGetValue(groupId, out group)) { group = new ActorGroup(groupId); this.actorGroups.Add(groupId, group); } actor.AddGroup(group); } } else { foreach (var group in this.actorGroups.Values) { actor.AddGroup(group); } } } }
public void AddGroup(ActorGroup group) { this.groups.Add(group); group.Add(this); }