示例#1
0
        public void ToggleMuteNotConnected()
        {
            Assert.DoesNotThrow(() =>
                                manager.ToggleMute(user));

            Assert.IsNull(manager.GetConnection(user));
        }
示例#2
0
        public static void Disconnect(this IServerUserManager self, IUserInfo user)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }

            var c = self.GetConnection(user);

            if (c != null)
            {
                self.Disconnect(c);
            }
        }
示例#3
0
        internal void OnSetPermissionsMessage(MessageEventArgs <SetPermissionsMessage> e)
        {
            var msg = e.Message;

            if (!e.Connection.IsConnected || !context.PermissionsProvider.UpdatedSupported)
            {
                return;
            }

            if (!context.GetPermission(PermissionName.ModifyPermissions, e.Connection))
            {
                e.Connection.SendAsync(new PermissionDeniedMessage(GablarskiMessageType.SetPermissions));
                return;
            }

            var perms = msg.Permissions.ToList();

            if (perms.Count == 0)
            {
                return;
            }

            context.PermissionsProvider.SetPermissions(msg.UserId, perms);

            IUserInfo target = Manager[msg.UserId];

            if (target == null)
            {
                return;
            }

            IConnection c = Manager.GetConnection(target);

            if (c != null)
            {
                c.SendAsync(new PermissionsMessage(msg.UserId, context.PermissionsProvider.GetPermissions(msg.UserId)));
            }
        }