예제 #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));
        }
예제 #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);
        }
예제 #3
0
 public ServerToClientMessage(LoginReply reply)
 {
     Type       = ServerToClientMessageType.LoginReply;
     LoginReply = reply;
 }