net.sf.freecol.common.networking
Class ChatMessage

java.lang.Object
  extended by net.sf.freecol.common.networking.Message
      extended by net.sf.freecol.common.networking.ChatMessage

public class ChatMessage
extends Message

The message that contains a chat string.


Constructor Summary
ChatMessage(Game game, org.w3c.dom.Element element)
          Create a new ChatMessage from a supplied element.
ChatMessage(Player player, java.lang.String message, boolean privateChat)
          Create a new ChatMessage with the supplied message.
 
Method Summary
 java.lang.String getMessage()
          What is the text of this ChatMessage?
 Player getPlayer()
          Who sent this ChatMessage?
static java.lang.String getXMLElementTagName()
          The tag name of the root element representing this object.
 org.w3c.dom.Element handle(FreeColServer server, Connection connection)
          Handle a "chat"-message.
 boolean isPrivate()
          Is this ChatMessage private?
 org.w3c.dom.Element toXMLElement()
          Convert this ChatMessage to XML.
 
Methods inherited from class net.sf.freecol.common.networking.Message
clientError, createError, createError, createNewDocument, createNewRootElement, getAttribute, getChildElement, getDocument, getFreeColProtocolVersion, getType, hasAttribute, insertAsRoot, isType, setAttribute, setAttribute, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatMessage

public ChatMessage(Player player,
                   java.lang.String message,
                   boolean privateChat)
Create a new ChatMessage with the supplied message.

Parameters:
player - The player that is sending the message.
message - The text of the message to send.
privateChat - Whether this message is private.

ChatMessage

public ChatMessage(Game game,
                   org.w3c.dom.Element element)
Create a new ChatMessage from a supplied element.

Parameters:
game - The Game this message belongs to.
element - The Element to use to create the message.
Throws:
java.lang.IllegalStateException - if there is problem with the senderID.
Method Detail

getPlayer

public Player getPlayer()
Who sent this ChatMessage?

Returns:
The name of the player that sent this ChatMessage.

getMessage

public java.lang.String getMessage()
What is the text of this ChatMessage?

Returns:
The text of this ChatMessage.

isPrivate

public boolean isPrivate()
Is this ChatMessage private?

Returns:
True if this ChatMessage is private.

handle

public org.w3c.dom.Element handle(FreeColServer server,
                                  Connection connection)
Handle a "chat"-message.

Parameters:
server - The FreeColServer that handles the message.
connection - The Connection message was received on.
Returns:
Null.

toXMLElement

public org.w3c.dom.Element toXMLElement()
Convert this ChatMessage to XML.

Overrides:
toXMLElement in class Message
Returns:
The XML representation of this message.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
The tag name of the root element representing this object.

Returns:
"chat".