/// <summary> /// Links channels together so that destination can hear source /// </summary> public void LinkChannel(int sourceID, int destinationID, bool oneWay = true) { var channels = server.getChannels(); // link channels var srcChan = channels[sourceID]; var dstChan = channels[destinationID]; srcChan.links = AddToArray(srcChan.links, destinationID); dstChan.links = AddToArray(dstChan.links, sourceID); server.setChannelState(srcChan); server.setChannelState(dstChan); if (oneWay) { // set ACL (dont let source hear destination) server.setACL(sourceID, new[] { new ACL(true, true, false, -1, "all", 0, (int)Permission.Speak), new ACL(true, true, false, -1, "in", (int)Permission.Speak, 0) }, null, true); } }
/// <summary> /// Update exist channel /// </summary> /// <param name="channel"></param> /// <param name="setAcl">add acls and groups?</param> public void UpdateChannel(VirtualServerEntity.Channel channel, bool setAcl = false) { // set channel info var state = new Channel(channel.Id, channel.Name, channel.ParentId, channel.Links, channel.Description, false, channel.Position); // WARNING! LINKS MUST BE VALID OR InvalidChannelException will be thrown _server.setChannelState(state); if (setAcl) { // set groups Group[] groups = new Group[channel.Groups.Count]; for (int i = 0; i < channel.Groups.Count; i++) { var g = channel.Groups[i]; groups[i] = new Group(g.Name, g.Inherited, g.Inherit, g.Inheritable, g.Add, g.Remove, g.Members); } // set acls ACL[] acls = new ACL[channel.Acls.Count]; for (int i = 0; i < channel.Acls.Count; i++) { var a = channel.Acls[i]; acls[i] = new ACL(a.ApplyHere, a.ApplySubs, a.Inherited, a.UserId, a.Group, a.Allow, a.Deny); } _server.setACL(channel.Id, acls, groups, channel.InheritAcl); } // update in cache if (_entity.Channels.ContainsKey(channel.Id)) { _entity.Channels[channel.Id] = channel; } else { _entity.Channels.Add(channel.Id, channel); } }