Esempio n. 1
0
        internal void RequestMuteSourceMessage(MessageEventArgs <RequestMuteSourceMessage> e)
        {
            var request = (RequestMuteMessage)e.Message;

            if (!e.Connection.IsConnected)
            {
                return;
            }

            if (!context.GetPermission(PermissionName.MuteAudioSource, e.Connection))
            {
                e.Connection.SendAsync(new PermissionDeniedMessage {
                    DeniedMessage = GablarskiMessageType.RequestMuteSource
                });
                return;
            }

            var source = manager[request.TargetId];

            if (source == null)
            {
                return;
            }

            bool muted = manager.ToggleMute(source);

            foreach (IConnection connection in this.context.Connections)
            {
                connection.SendAsync(new SourceMutedMessage {
                    SourceId = source.Id, Unmuted = !muted
                });
            }
        }
        public void ClientAudioSourceStateChangedSourceMuted()
        {
            var u = UserInfoTests.GetTestUser(2, 1, false);

            var cs = provider.GetConnections(GablarskiProtocol.Instance);
            var c  = cs.Item2;
            var cl = new ConnectionBuffer(cs.Item1);

            userManager.Connect(c);
            userManager.Join(c, u);

            var s = manager.Create("Name", u, new AudioCodecArgs());

            manager.ToggleMute(s);

            handler.ClientAudioSourceStateChangeMessage(new MessageEventArgs <ClientAudioSourceStateChangeMessage> (c,
                                                                                                                    new ClientAudioSourceStateChangeMessage {
                SourceId = s.Id, Starting = true
            }));

            client.AssertNoMessage();
            cl.AssertNoMessage();
        }