feud.testgame
Class BlueThunderServer

java.lang.Object
  extended byfeud.testgame.BlueThunderServer
All Implemented Interfaces:
ClientLoginListener, ClientLogoutListener, DataTransferListener, java.lang.Runnable

public class BlueThunderServer
extends java.lang.Object
implements DataTransferListener, java.lang.Runnable, ClientLoginListener, ClientLogoutListener

This is this test game's server component. It's usually started from within a running client but can run as a stand-alone server as well.


Constructor Summary
BlueThunderServer()
          Starts a new server using the default tcp-port.
BlueThunderServer(int port)
          Starts a new server using a specified tcp-port.
 
Method Summary
 void addScores(InfoDataContainer idc)
          Adds the scores to a highscore table (a GUI-element).
 void broadcast(DataContainer dc)
          Broadcasts data to all clients.
 DataContainer[] dataReceived(DataContainer c, int type)
          Data has been received by the server/client to which this listener has been added.
 void dataReceivedEnd()
          The server/client has finished receiving in this transfer.
 PlayerInfo getPlayerInfo(int clientID)
          Gets the player info a client's ID.
 DataContainer loggedIn(ClientInfo ci, DataContainer dc)
          A client has been logged in.
 DataContainer loggedOut(ClientInfo ci)
          A client has been logged out.
static void main(java.lang.String[] args)
          Run the server as stand-alone.
 void remove(int loID, int clientID, ClientInfo ci)
          Removes an object from the server
 void run()
           
 void stop()
          Stops the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlueThunderServer

public BlueThunderServer()
Starts a new server using the default tcp-port.


BlueThunderServer

public BlueThunderServer(int port)
Starts a new server using a specified tcp-port.

Parameters:
port - int the port
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Run the server as stand-alone.

Parameters:
args - String[]
Throws:
java.lang.Exception

loggedOut

public DataContainer loggedOut(ClientInfo ci)
Description copied from interface: ClientLogoutListener
A client has been logged out.

Specified by:
loggedOut in interface ClientLogoutListener
Parameters:
ci - the ClientInfo of the logged out client
Returns:
DataContainer an optional DataContainer (may be null) that the server will broadcast to all other clients (usually a "XXX logged out" message or something).

loggedIn

public DataContainer loggedIn(ClientInfo ci,
                              DataContainer dc)
Description copied from interface: ClientLoginListener
A client has been logged in.

Specified by:
loggedIn in interface ClientLoginListener
Parameters:
ci - the ClientInfo of the logged in client
Returns:
DataContainer an optional DataContainer (may be null) that the server will broadcast to all other clients (usually a "XXX logged in" message or something).

run

public void run()
Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stops the server.


dataReceivedEnd

public void dataReceivedEnd()
Description copied from interface: DataTransferListener
The server/client has finished receiving in this transfer. This method will be called once after receiving all data, while the one above can be called multiple times while receiving.

Specified by:
dataReceivedEnd in interface DataTransferListener

getPlayerInfo

public PlayerInfo getPlayerInfo(int clientID)
Gets the player info a client's ID.

Parameters:
clientID - int the ID
Returns:
PlayerInfo the player info

broadcast

public void broadcast(DataContainer dc)
Broadcasts data to all clients.

Parameters:
dc - DataContainer the container with the data to broadcast

remove

public void remove(int loID,
                   int clientID,
                   ClientInfo ci)
Removes an object from the server

Parameters:
loID - int
clientID - int
ci - ClientInfo

dataReceived

public DataContainer[] dataReceived(DataContainer c,
                                    int type)
Description copied from interface: DataTransferListener
Data has been received by the server/client to which this listener has been added. This method will be called for each DataContainer. A transfer can consist of many DataContainers.

Specified by:
dataReceived in interface DataTransferListener
Parameters:
c - the DataContainer that has been received.
type - the type of the message like MessageType defines it
Returns:
DataContainer[] an optional result. The client doesn't care for this result. The server will send it back to the client from which is has received the data.

addScores

public void addScores(InfoDataContainer idc)
Adds the scores to a highscore table (a GUI-element).

Parameters:
idc - InfoDataContainer the info container containing the scores