nl.bluering.ppracing
Class NetSClient

java.lang.Object
  |
  +--nl.bluering.ppracing.NetSClient

public class NetSClient
extends java.lang.Object

This class provides the functionality for playing a network game as server. It takes care of the communication with the clients


Field Summary
 boolean[] enabled
           
 
Constructor Summary
NetSClient(Ppracing p, java.lang.String n, newnetwindow nw)
          Creates a new server-client and starts the server
 
Method Summary
 void addplayer(java.net.Socket s)
          Adds a player and creates in/outcoming connections
 void doremove()
          This method removes all marked players.
 void endgame(java.lang.String s)
          The server ends the game
 int getid()
           
 java.lang.String[] getplayerlist()
           
 int[] getplayertype()
           
 void indisconnect(int id)
          A client disconnects from the server
 void inmessage(int id, java.lang.String s)
          The server gets a message from a player The message goes to all other players
 void inmove(int id, java.lang.String s)
          A player sends a move to the server
 void inname(int i, java.lang.String s)
          This function is called by NetReceive, to set the name of the connected player.
 void outcircuit()
          The server sends the circuit to all players
 void outdisconnect(int id)
          The server disconnects a client
 void outmessage(java.lang.String s)
          The server sends a message to the players The message goes to all other players
 void outmove(int m)
          The server does a move
 void outname()
          Sends the player-list to all connected players
 void removeplayer(int id)
          This method disables the player on the given ID.
 void showmessage(java.lang.String s)
          Shows a message on the chatbox in the newnetwin
 void startgame()
          The server starts the game
 void stop()
          Stops the server and terminates all connections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enabled

public boolean[] enabled
Constructor Detail

NetSClient

public NetSClient(Ppracing p,
                  java.lang.String n,
                  newnetwindow nw)
           throws java.io.IOException
Creates a new server-client and starts the server
Method Detail

addplayer

public void addplayer(java.net.Socket s)
Adds a player and creates in/outcoming connections

removeplayer

public void removeplayer(int id)
This method disables the player on the given ID.

doremove

public void doremove()
This method removes all marked players.

inname

public void inname(int i,
                   java.lang.String s)
This function is called by NetReceive, to set the name of the connected player.

outname

public void outname()
Sends the player-list to all connected players

getid

public int getid()
Returns:
the ID of the server

outmessage

public void outmessage(java.lang.String s)
The server sends a message to the players The message goes to all other players

inmessage

public void inmessage(int id,
                      java.lang.String s)
The server gets a message from a player The message goes to all other players

outmove

public void outmove(int m)
The server does a move

inmove

public void inmove(int id,
                   java.lang.String s)
A player sends a move to the server

startgame

public void startgame()
The server starts the game

endgame

public void endgame(java.lang.String s)
The server ends the game

indisconnect

public void indisconnect(int id)
A client disconnects from the server

outdisconnect

public void outdisconnect(int id)
The server disconnects a client

outcircuit

public void outcircuit()
The server sends the circuit to all players

stop

public void stop()
Stops the server and terminates all connections

getplayerlist

public java.lang.String[] getplayerlist()
Returns:
The list of currently connected players

getplayertype

public int[] getplayertype()
Returns:
The list of types of the connected players

showmessage

public void showmessage(java.lang.String s)
Shows a message on the chatbox in the newnetwin