net.sf.freecol.server.networking
Class DummyConnection

java.lang.Object
  extended by net.sf.freecol.common.networking.Connection
      extended by net.sf.freecol.server.networking.DummyConnection

public final class DummyConnection
extends Connection

A dummy connection, used for AI players.


Constructor Summary
DummyConnection(java.lang.String name, MessageHandler incomingMessageHandler)
          Sets up a dummy connection using the specified MessageHandlers.
 
Method Summary
 org.w3c.dom.Element ask(org.w3c.dom.Element element)
          Sends a message to the other peer and returns the reply.
 void close()
          Closes this connection.
 DummyConnection getOtherConnection()
          Gets the DummyConnection this object is connected to.
 void send(org.w3c.dom.Element element)
          Sends the given message over this Connection.
 void sendAndWait(org.w3c.dom.Element element)
          Sends the given message over this Connection and waits for confirmation of receiveval before returning.
 void setOutgoingMessageHandler(DummyConnection c)
          Sets the outgoing MessageHandler for this Connection.
 java.lang.String toString()
          Return a human-readable string with the dummy connection name.
 
Methods inherited from class net.sf.freecol.common.networking.Connection
ask, endTransmission, getMessageHandler, getReply, getSocket, handleAndSendReply, reallyClose, send, setMessageHandler
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DummyConnection

public DummyConnection(java.lang.String name,
                       MessageHandler incomingMessageHandler)
Sets up a dummy connection using the specified MessageHandlers.

Parameters:
name - The name that identifies the connection.
incomingMessageHandler - The MessageHandler to call for each message received.
Method Detail

close

public void close()
           throws java.io.IOException
Closes this connection.

Overrides:
close in class Connection
Throws:
java.io.IOException - Will not be thrown by a DummyConnection, but added because of the superclass' specification.

send

public void send(org.w3c.dom.Element element)
          throws java.io.IOException
Sends the given message over this Connection.

Overrides:
send in class Connection
Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information
Throws:
java.io.IOException - If an error occur while sending the message.
See Also:
sendAndWait(Element), ask(Element)

ask

public org.w3c.dom.Element ask(org.w3c.dom.Element element)
                        throws java.io.IOException
Sends a message to the other peer and returns the reply.

Overrides:
ask in class Connection
Parameters:
element - The question for the other peer.
Returns:
The reply from the other peer.
Throws:
java.io.IOException - If an error occur while sending the message.
See Also:
send(org.w3c.dom.Element), sendAndWait(org.w3c.dom.Element)

sendAndWait

public void sendAndWait(org.w3c.dom.Element element)
                 throws java.io.IOException
Sends the given message over this Connection and waits for confirmation of receiveval before returning.

Overrides:
sendAndWait in class Connection
Parameters:
element - The element (root element in a DOM-parsed XML tree) that holds all the information
Throws:
java.io.IOException - If an error occur while sending the message.
See Also:
send(Element), ask(Element)

setOutgoingMessageHandler

public void setOutgoingMessageHandler(DummyConnection c)
Sets the outgoing MessageHandler for this Connection.

Parameters:
c - The connectio to get the messagehandler from.

getOtherConnection

public DummyConnection getOtherConnection()
Gets the DummyConnection this object is connected to.

Returns:
The DummyConnection .

toString

public java.lang.String toString()
Return a human-readable string with the dummy connection name.

Overrides:
toString in class Connection
Returns:
string for debugging.