Exemplo n.º 1
0
        private void ClientsClientConnect(object sender, ClientConnectedEventArgs e)
        {
            IClientInterceptor client = (IClientInterceptor)e.NewClient;

            this.commandAuthorizations.Add(client, new CommandAuthorization(client, this.commandCollection));
            client.Disconnect += this.ClientDisconnect;
        }
Exemplo n.º 2
0
        private void AccountControllerClientLoggedIn(object sender, LogedInOrOutEventArgs e)
        {
            IClientInterceptor client = (IClientInterceptor)e.Client;

            CommandAuthorization authorization = this.commandAuthorizations[client];

            authorization.IsLoggedIn = false;
        }
Exemplo n.º 3
0
        private void AccountControllerClientLoggedOut(object sender, LogedInOrOutEventArgs e)
        {
            IClientInterceptor client = (IClientInterceptor)e.Client;

            // Most important remove all permissions if a client is logged out.
            CommandAuthorization authorization = this.commandAuthorizations[client];

            authorization.Reset();
            authorization.IsLoggedIn = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandAuthorization"/> class.
        /// </summary>
        /// <param name="client">The client object for which this instance of  <see cref="CommandAuthorization"/> should authorize commands.</param>
        /// <param name="commandCollection">The <see cref="CommandCollection"/> that provides the access to the available commands.</param>
        public CommandAuthorization(IClientInterceptor client, CommandCollection commandCollection)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (commandCollection == null)
            {
                throw new ArgumentNullException(nameof(commandCollection));
            }

            this.client                        = client;
            this.commandCollection             = commandCollection;
            this.client.BeforeCommandReceived += this.InvokeCommand;
            this.client.Disconnect            += this.ClientDisconnect;
        }