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