monrovia.protocol.server
Class ServerUdpSender

java.lang.Object
  |
  +--monrovia.protocol.server.ServerUdpSender

public class ServerUdpSender
extends java.lang.Object

This class is used to send UDP message to a single client.


Constructor Summary
ServerUdpSender(java.io.BufferedOutputStream pOutputStream)
          Constructor
ServerUdpSender(java.net.DatagramSocket pDatagramSocket, java.net.InetAddress pInetAddress, int pClientPort)
          Constructor
 
Method Summary
 void addCommand(Command pCmd)
          addCommand adds or removes a command to the clients command collection
 void addMessage(java.lang.String pMessage)
          addMessage sends a message to the client
 void addObject(int pId, int pXDelta, int pYDelta)
          addObject sets a dynamic object to a location
 void addStat(int pStatID, int pValue)
          addStat informs the client of a changed int stat
 void addStat(int pStatID, java.lang.String pValue)
          addStat informs the client of a change string stat
 void flush()
          flush sends the packet to the client
 void newTurn(int pXMap, int pYMap)
          newTurn initializes a new udp message
 void startSending()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerUdpSender

public ServerUdpSender(java.net.DatagramSocket pDatagramSocket,
                       java.net.InetAddress pInetAddress,
                       int pClientPort)
Constructor
Parameters:
pDatagramSocket - an already allocated DatagramSocket
pInetAddress - the address of the receiver
pClientPort - the port of the receiver

ServerUdpSender

public ServerUdpSender(java.io.BufferedOutputStream pOutputStream)
Constructor
Parameters:
pDataOutpuStream - the outputstream
Method Detail

startSending

public void startSending()

newTurn

public void newTurn(int pXMap,
                    int pYMap)
newTurn initializes a new udp message
Parameters:
pXMap - the x coordinate where the client is now
pYMap - the y coordinate

flush

public void flush()
flush sends the packet to the client

addObject

public void addObject(int pId,
                      int pXDelta,
                      int pYDelta)
addObject sets a dynamic object to a location
Parameters:
pId - the object id
pXDelta - the x distance from the player
pYDelta - the y distance

addStat

public void addStat(int pStatID,
                    int pValue)
addStat informs the client of a changed int stat
Parameters:
pStatID - the stats id
pValue - the value

addStat

public void addStat(int pStatID,
                    java.lang.String pValue)
addStat informs the client of a change string stat
Parameters:
pStatID - the stats id
pValue - the value

addCommand

public void addCommand(Command pCmd)
addCommand adds or removes a command to the clients command collection
Parameters:
pCmd - the command to be sent

addMessage

public void addMessage(java.lang.String pMessage)
addMessage sends a message to the client
Parameters:
pMessage - the message to be sent