gecco.communication.server
Class DataOutputExchangeHandler

java.lang.Object
  |
  +--gecco.communication.server.DataOutputExchangeHandler
All Implemented Interfaces:
Runnable

public class DataOutputExchangeHandler
extends Object
implements Runnable

a class that listens for incoming messages from the client, receives them, and tells the server about them

Author:
Niklas Hallenfur, Henrik Hägerström, Jon Åslund

Field Summary
private  ClientConnection connection
          Description of the Field
private  boolean disconnect
          Description of the Field
private  ClientConnectionHandler i_am_working_for
          Description of the Field
private  MessageQueue messages_to_send
          Description of the Field
 Boolean pingSyncObject
          Description of the Field
private  Server server
          Description of the Field
 
Constructor Summary
DataOutputExchangeHandler(MessageQueue q, ClientConnection cc, Server se, ClientConnectionHandler cch)
          Constructor for the DataOutputExchangeHandler object
 
Method Summary
 void abortGame()
          called when the client says it wants to abort the game or disconnect
 void addMessageToQueue(Object message)
          Adds a feature to the MessageToQueue attribute of the DataOutputExchangeHandler object
 void kill()
          called whenever someone wants this Thread to die
private  void ping()
          send a 'ping' to see if this client is available
 void run()
          Main processing method for the DataOutputExchangeHandler object
private  void sendActionBlocked(ActionBlockedMessage m)
          Description of the Method
private  void sendActionCompleted(ActionCompletedMessage m)
          Description of the Method
private  void sendActionFailed(ActionFailedMessage m)
          Description of the Method
private  void sendMapPointInvisible(MapPointInvisibleMessage m)
          Description of the Method
private  void sendMapPointsInvisible(MapPointsInvisibleMessage m)
          Description of the Method
private  void sendMapUpdate(MapUpdateMessage m)
          Description of the Method
private  void sendMapUpdates(MapUpdatesMessage m)
          Description of the Method
private  void sendMessage(Object m)
          Called when a message is to be sent Checks the class of the object to send, and calls the appropriate method that sends that kind of object
private  void sendUnitDeleted(UnitDeletedMessage m)
          Description of the Method
private  void sendUnitDestroyed(UnitDestroyedMessage m)
          Description of the Method
private  void sendUnitMessage(UnitMessageMessage m)
          Description of the Method
private  void sendUnitPositionUpdate(UnitPositionUpdateMessage m)
          Sends a message that tells the client the new position of a unit
private  void sendUnitPropertiesUpdate(UnitPropertyChangedMessage m)
          sends a message that tells the client the new values of the properties of a unit
private  void sendUnitVisible(UnitVisibleMessage m)
          sends a message that tells the client that a new unit is visible
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

pingSyncObject

public Boolean pingSyncObject
Description of the Field

messages_to_send

private MessageQueue messages_to_send
Description of the Field

connection

private ClientConnection connection
Description of the Field

server

private Server server
Description of the Field

i_am_working_for

private ClientConnectionHandler i_am_working_for
Description of the Field

disconnect

private boolean disconnect
Description of the Field
Constructor Detail

DataOutputExchangeHandler

public DataOutputExchangeHandler(MessageQueue q,
                                 ClientConnection cc,
                                 Server se,
                                 ClientConnectionHandler cch)
Constructor for the DataOutputExchangeHandler object
Parameters:
q - Description of Parameter
cc - Description of Parameter
se - Description of Parameter
cch - Description of Parameter
Method Detail

addMessageToQueue

public void addMessageToQueue(Object message)
Adds a feature to the MessageToQueue attribute of the DataOutputExchangeHandler object
Parameters:
message - The feature to be added to the MessageToQueue attribute

run

public void run()
Main processing method for the DataOutputExchangeHandler object
Specified by:
run in interface Runnable

abortGame

public void abortGame()
called when the client says it wants to abort the game or disconnect

kill

public void kill()
called whenever someone wants this Thread to die

sendMessage

private void sendMessage(Object m)
                  throws Exception
Called when a message is to be sent Checks the class of the object to send, and calls the appropriate method that sends that kind of object
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendUnitPositionUpdate

private void sendUnitPositionUpdate(UnitPositionUpdateMessage m)
                             throws Exception
Sends a message that tells the client the new position of a unit
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendUnitPropertiesUpdate

private void sendUnitPropertiesUpdate(UnitPropertyChangedMessage m)
                               throws Exception
sends a message that tells the client the new values of the properties of a unit
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendUnitVisible

private void sendUnitVisible(UnitVisibleMessage m)
                      throws Exception
sends a message that tells the client that a new unit is visible
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendUnitDeleted

private void sendUnitDeleted(UnitDeletedMessage m)
                      throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendUnitMessage

private void sendUnitMessage(UnitMessageMessage m)
                      throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendUnitDestroyed

private void sendUnitDestroyed(UnitDestroyedMessage m)
                        throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendActionBlocked

private void sendActionBlocked(ActionBlockedMessage m)
                        throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendMapUpdate

private void sendMapUpdate(MapUpdateMessage m)
                    throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendMapUpdates

private void sendMapUpdates(MapUpdatesMessage m)
                     throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendMapPointsInvisible

private void sendMapPointsInvisible(MapPointsInvisibleMessage m)
                             throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendMapPointInvisible

private void sendMapPointInvisible(MapPointInvisibleMessage m)
                            throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendActionCompleted

private void sendActionCompleted(ActionCompletedMessage m)
                          throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

sendActionFailed

private void sendActionFailed(ActionFailedMessage m)
                       throws Exception
Description of the Method
Parameters:
m - Description of Parameter
Throws:
Exception - Description of Exception

ping

private void ping()
           throws Exception
send a 'ping' to see if this client is available
Throws:
Exception - Description of Exception