Ejemplo n.º 1
0
        void OnLoginRequest(ClientToServerMessage message)
        {
            LoginRequest request = message.LoginRequest;

            if (request == null)
            {
                throw new ServerClientException("Invalid login request");
            }
            LoginReply reply = Server.OnLoginRequest(request);

            if (reply.Type == LoginReplyType.Success)
            {
                _Name = request.Name;
                LoggedInState();
            }
            QueueMessage(new ServerToClientMessage(reply));
        }
Ejemplo n.º 2
0
        public LoginReply OnLoginRequest(LoginRequest request)
        {
            LoginReplyType replyType;

            if (!IsCompatibleClientVersion(request.ClientVersion))
            {
                replyType = LoginReplyType.IncompatibleVersion;
            }
            else if (NameIsTooLong(request.Name))
            {
                replyType = LoginReplyType.NameTooLong;
            }
            else if (NameIsInUse(request.Name))
            {
                replyType = LoginReplyType.NameInUse;
            }
            else
            {
                replyType = LoginReplyType.Success;
            }
            LoginReply reply = new LoginReply(replyType, Version);

            return(reply);
        }
Ejemplo n.º 3
0
 public ServerToClientMessage(LoginReply reply)
 {
     Type       = ServerToClientMessageType.LoginReply;
     LoginReply = reply;
 }