From: Hendrik B. <nh...@us...> - 2010-02-08 14:59:09
|
Update of /cvsroot/arianne/marauroa/src/marauroa/common/net/message In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13536/src/marauroa/common/net/message Modified Files: Message.java Added Files: MessageS2CLoginMessageNACK.java Log Message: protocol and client side support for arbitrary error message on rejected login (#2947337) --- NEW FILE: MessageS2CLoginMessageNACK.java --- /* $Id: MessageS2CLoginMessageNACK.java,v 1.1 2010/02/08 14:58:59 nhnb Exp $ */ /*************************************************************************** * (C) Copyright 2010 - Marauroa * *************************************************************************** *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ package marauroa.common.net.message; import java.io.IOException; import java.nio.channels.SocketChannel; /** * This message indicate the client that the server has reject its login Message * * @see marauroa.common.net.message.Message */ public class MessageS2CLoginMessageNACK extends Message { /** The reason of login rejection */ private String reason; /** Constructor for allowing creation of an empty message */ public MessageS2CLoginMessageNACK() { super(MessageType.S2C_LOGIN_MESSAGE_NACK, null); } /** * Constructor with a TCP/IP source/destination of the message * * @param source * The TCP/IP address associated to this message * @param reason * the reason to deny the login */ public MessageS2CLoginMessageNACK(SocketChannel source, String reason) { super(MessageType.S2C_LOGIN_MESSAGE_NACK, source); this.reason = reason; if (this.reason.length() > 250) { this.reason = this.reason.substring(0, 250); } } /** * This method returns the reason for the rejection of the login event * * @return reason. */ public String getReason() { return reason; } /** * This method returns a String that represent the object * * @return a string representing the object. */ @Override public String toString() { return "Message (S2C Login NACK) from (" + getAddress() + ") CONTENTS: (" + reason + ")"; } @Override public void writeObject(marauroa.common.net.OutputSerializer out) throws IOException { super.writeObject(out); out.write255LongString(reason); } @Override public void readObject(marauroa.common.net.InputSerializer in) throws IOException { super.readObject(in); reason = in.read255LongString(); if (type != MessageType.S2C_LOGIN_NACK) { throw new IOException(); } } }; Index: Message.java =================================================================== RCS file: /cvsroot/arianne/marauroa/src/marauroa/common/net/message/Message.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Message.java 9 Nov 2009 21:24:11 -0000 1.13 --- Message.java 8 Feb 2010 14:58:59 -0000 1.14 *************** *** 1,5 **** /* $Id$ */ /*************************************************************************** ! * (C) Copyright 2003 - Marauroa * *************************************************************************** *************************************************************************** --- 1,5 ---- /* $Id$ */ /*************************************************************************** ! * (C) Copyright 2003-2010 - Marauroa * *************************************************************************** *************************************************************************** *************** *** 64,68 **** S2C_CREATECHARACTER_NACK, S2C_CONNECT_NACK, ! C2S_LOGIN_SENDNONCENAMEPASSWORDANDSEED } --- 64,69 ---- S2C_CREATECHARACTER_NACK, S2C_CONNECT_NACK, ! C2S_LOGIN_SENDNONCENAMEPASSWORDANDSEED, ! S2C_LOGIN_MESSAGE_NACK } |