GetUser() public method

public GetUser ( NetworkNode connectedNode ) : UserInfo
connectedNode NetworkNode
return UserInfo
Exemplo n.º 1
0
        bool ReceiveMessage_TextToServer(NetworkNode.ConnectedNode sender,
                                         MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage)
        {
            //get source user
            UserManagementServerNetworkService.UserInfo fromUser = userManagementService.
                                                                   GetUser(sender);

            //get data of message
            string text = reader.ReadString();
            uint   privateToUserIdentifier = reader.ReadVariableUInt32();

            if (!reader.Complete())
            {
                return(false);
            }

            //send text to the clients
            if (privateToUserIdentifier != 0)
            {
                //send text to the specific user

                UserManagementServerNetworkService.UserInfo privateToUser = userManagementService.
                                                                            GetUser(privateToUserIdentifier);
                if (privateToUser != null)
                {
                    SendText(fromUser, text, privateToUser);
                }
                else
                {
                    //no user anymore
                }
            }
            else
            {
                SendText(fromUser, text, null);
            }

            return(true);
        }
Exemplo n.º 2
0
        protected override void OnConnectedNodeConnectionStatusChanged(
            NetworkNode.ConnectedNode connectedNode, NetworkConnectionStatuses status, string message)
        {
            base.OnConnectedNodeConnectionStatusChanged(connectedNode, status, message);

            //connected
            if (status == NetworkConnectionStatuses.Connected)
            {
                //add to user management and send events to all clients
                userManagementService.CreateClientUser(connectedNode);
            }

            //disconnected
            if (status == NetworkConnectionStatuses.Disconnected)
            {
                //remove user
                UserManagementServerNetworkService.UserInfo user = userManagementService.GetUser(
                    connectedNode);
                if (user != null)
                {
                    userManagementService.RemoveUser(user);
                }
            }
        }