Ejemplo n.º 1
0
        /// <summary>
        /// Raises when a list of client names has been received.
        /// </summary>
        /// <param name="content">Content that lists the names of all clients logged in.</param>
        protected override void OnNamesReceived(ClientNamesContent content)
        {
            clientNames.Clear();

            foreach (var n in content.Names)
            {
                clientNames.Add(n);
            }

            Pusher.Push(content);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises when a client received a completed <see cref="Package"/>.
        /// Not calling the base implementation of this methods will cause the client
        /// to malfunction.
        /// </summary>
        /// <param name="package">The package that has been received.</param>
        protected virtual void OnPackageReceived(Package package)
        {
            switch ((BaseCommand)package.Command)
            {
            case BaseCommand.Logout:
                var content = LogoutContent.Deserialize(package.Content);
                OnLoggedOut(content);
                break;

            case BaseCommand.ClientNames:
                var c = ClientNamesContent.Deserialize(package.Content);
                OnNamesReceived(c);
                break;

            case BaseCommand.Login:
                var loginContent = LoginContent.Deserialize(package.Content);
                OnLoggedIn(loginContent);
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sends the names of all of the clients which are logged in to a specified client.
        /// </summary>
        /// <param name="client">The client to send the names to.</param>
        private void SendClientNames(ServerSideClient client)
        {
            var contents = new ClientNamesContent(clients.Select(c => c.Name).ToArray());

            client.SendPackageAsync((int)BaseCommand.ClientNames, contents);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Raises when a list of client names has been received.
 /// </summary>
 /// <param name="content">Content that lists the names of all clients logged in.</param>
 protected virtual void OnNamesReceived(ClientNamesContent content)
 {
 }