nl.bluering.ppracing
Class NetReceive

java.lang.Object
  |
  +--nl.bluering.ppracing.NetReceive
All Implemented Interfaces:
java.lang.Runnable

public class NetReceive
extends java.lang.Object
implements java.lang.Runnable

This class implements the procedures for receiving data from the server or a client


Constructor Summary
NetReceive(java.net.Socket s, int i, NetClient n)
          Creates a new platform for the client to receive messages from the specified server
NetReceive(java.net.Socket s, int i, NetSClient n)
          Creates a new platform for the server to receive messages from the specified client
 
Method Summary
 void acknowledge(int id)
          The client receives it's ID from the server
 void carmove(int id, java.lang.String s)
          Is called when a player has moved it's car
 void circuit(java.lang.String s)
          Is called when a client receives the circuit from the server
 void decode(java.lang.String s)
          This functions decodes the specified message string, and calls the appropriate function
 void disconnect(int id)
          Either a client disconnects from the server or the server disconnects this client
 void endgame()
          Is called when the server ends the game
 void message(int id, java.lang.String s)
          Is called when a message from the server or a client is received
 void newgame()
          Is called when the server sends a newgame-request
 void players(java.lang.String s)
          Is called when a list of players is received, the list needs decoding.
 void run()
          Is called when the thread is started This function keeps checking for new messages, until stopped
 void setid(int id)
          Sets the ID of the client, only needed for feedback when debugging
 void setname(int id, java.lang.String s)
          Is called when a client sends it's name to the server
 void start()
          Starts this class in a new thread
 void stop()
          Stops this Thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetReceive

public NetReceive(java.net.Socket s,
                  int i,
                  NetClient n)
Creates a new platform for the client to receive messages from the specified server

NetReceive

public NetReceive(java.net.Socket s,
                  int i,
                  NetSClient n)
Creates a new platform for the server to receive messages from the specified client
Method Detail

setid

public void setid(int id)
Sets the ID of the client, only needed for feedback when debugging

start

public void start()
Starts this class in a new thread

stop

public void stop()
Stops this Thread

run

public void run()
Is called when the thread is started This function keeps checking for new messages, until stopped
Specified by:
run in interface java.lang.Runnable

decode

public void decode(java.lang.String s)
This functions decodes the specified message string, and calls the appropriate function

acknowledge

public void acknowledge(int id)
The client receives it's ID from the server

disconnect

public void disconnect(int id)
Either a client disconnects from the server or the server disconnects this client

players

public void players(java.lang.String s)
Is called when a list of players is received, the list needs decoding.

message

public void message(int id,
                    java.lang.String s)
Is called when a message from the server or a client is received

newgame

public void newgame()
Is called when the server sends a newgame-request

carmove

public void carmove(int id,
                    java.lang.String s)
Is called when a player has moved it's car

endgame

public void endgame()
Is called when the server ends the game

setname

public void setname(int id,
                    java.lang.String s)
Is called when a client sends it's name to the server

circuit

public void circuit(java.lang.String s)
Is called when a client receives the circuit from the server