games.strategy.engine.message
Class DummyMessenger

java.lang.Object
  extended by games.strategy.engine.message.DummyMessenger
All Implemented Interfaces:
IMessenger, IServerMessenger

public class DummyMessenger
extends java.lang.Object
implements IServerMessenger

A messenger that doesnt do anything.


Constructor Summary
DummyMessenger()
           
 
Method Summary
 void addConnectionChangeListener(IConnectionChangeListener listener)
          Add a listener for change in connection status.
 void addErrorListener(IMessengerErrorListener listener)
          Listen for messages of a certain type.
 void addMessageListener(IMessageListener listener)
          Listen for messages of a certain type.
 void broadcast(java.io.Serializable msg)
          Send a message to all nodes.
 void flush()
          Returns when all messages have been written over the network. shutdown causes this method to return.
 INode getLocalNode()
          Get the local node
 ILoginValidator getLoginValidator()
           
 java.util.Set<INode> getNodes()
          Get a list of nodes.
 java.net.InetSocketAddress getRemoteServerSocketAddress()
          Get the socket address to which we talk to the server.
 INode getServerNode()
           
 boolean isAcceptNewConnections()
           
 boolean isConnected()
          test the connection.
 boolean isServer()
          Am I the server node?
 void removeConnection(INode node)
          Remove the node from the network.
 void removeConnectionChangeListener(IConnectionChangeListener listener)
          Remove a listener for change in connection status.
 void removeErrorListener(IMessengerErrorListener listener)
          Stop listening to messages.
 void removeMessageListener(IMessageListener listener)
          Stop listening to messages.
 void send(java.io.Serializable msg, INode to)
          Send a message to the given node.
 void setAcceptNewConnections(boolean accept)
           
 void setLoginValidator(ILoginValidator loginValidator)
           
 void shutDown()
          Shut the connection down.
 void waitForAllMessagsToBeProcessed()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DummyMessenger

public DummyMessenger()
Method Detail

send

public void send(java.io.Serializable msg,
                 INode to)
Send a message to the given node. Returns immediately.

Specified by:
send in interface IMessenger

broadcast

public void broadcast(java.io.Serializable msg)
Send a message to all nodes.

Specified by:
broadcast in interface IMessenger

addMessageListener

public void addMessageListener(IMessageListener listener)
Listen for messages of a certain type.

Specified by:
addMessageListener in interface IMessenger

removeMessageListener

public void removeMessageListener(IMessageListener listener)
Stop listening to messages.

Specified by:
removeMessageListener in interface IMessenger

addErrorListener

public void addErrorListener(IMessengerErrorListener listener)
Listen for messages of a certain type.

Specified by:
addErrorListener in interface IMessenger

removeErrorListener

public void removeErrorListener(IMessengerErrorListener listener)
Stop listening to messages.

Specified by:
removeErrorListener in interface IMessenger

getLocalNode

public INode getLocalNode()
Get the local node

Specified by:
getLocalNode in interface IMessenger

getNodes

public java.util.Set<INode> getNodes()
Get a list of nodes.

Specified by:
getNodes in interface IServerMessenger

isConnected

public boolean isConnected()
test the connection.

Specified by:
isConnected in interface IMessenger

shutDown

public void shutDown()
Shut the connection down.

Specified by:
shutDown in interface IMessenger

addConnectionChangeListener

public void addConnectionChangeListener(IConnectionChangeListener listener)
Add a listener for change in connection status.

Specified by:
addConnectionChangeListener in interface IServerMessenger

removeConnectionChangeListener

public void removeConnectionChangeListener(IConnectionChangeListener listener)
Remove a listener for change in connection status.

Specified by:
removeConnectionChangeListener in interface IServerMessenger

flush

public void flush()
Returns when all messages have been written over the network. shutdown causes this method to return. Does not gaurantee that the messages have reached their destination.


setAcceptNewConnections

public void setAcceptNewConnections(boolean accept)
Specified by:
setAcceptNewConnections in interface IServerMessenger

waitForAllMessagsToBeProcessed

public void waitForAllMessagsToBeProcessed()

isServer

public boolean isServer()
Description copied from interface: IMessenger
Am I the server node? There should only be one server node, and it should exist before other nodes.

Specified by:
isServer in interface IMessenger

isAcceptNewConnections

public boolean isAcceptNewConnections()
Specified by:
isAcceptNewConnections in interface IServerMessenger

removeConnection

public void removeConnection(INode node)
Description copied from interface: IServerMessenger
Remove the node from the network.

Specified by:
removeConnection in interface IServerMessenger

getServerNode

public INode getServerNode()
Specified by:
getServerNode in interface IMessenger
Returns:
local node if we are a server node.

setLoginValidator

public void setLoginValidator(ILoginValidator loginValidator)
Specified by:
setLoginValidator in interface IServerMessenger

getLoginValidator

public ILoginValidator getLoginValidator()
Specified by:
getLoginValidator in interface IServerMessenger

getRemoteServerSocketAddress

public java.net.InetSocketAddress getRemoteServerSocketAddress()
Description copied from interface: IMessenger
Get the socket address to which we talk to the server. This may be different than getServerNode().getSocketAddress() since the server will report the socket that he thinks the server is running on, if the server is behind a firewall, or a NAT, then this socket will be different than the actual port we use.

Specified by:
getRemoteServerSocketAddress in interface IMessenger