Class ServerCommandHandler

java.lang.Object
  extended byServerCommandHandler

public class ServerCommandHandler
extends java.lang.Object

Class ServerCommandHandler handles the server commands.

The user of the server can give it commands in the console. ServerCommandHandler takes care of receiving and handling these commands.

Version:
1.0
Author:
Stefan Brockmann, Tero Kuusela
See Also:
Server

Field Summary
private  Server s
           
 
Constructor Summary
ServerCommandHandler(Server srv)
          Constructor.
 
Method Summary
protected  void kickAll()
          Kicks all the players out from the server.
protected  void kickPlayer(int id)
          Kicks the given player out from the server.
protected  void printHelp()
          Prints out helpful text.
protected  void printPlayers()
          Prints out the players currently connected to the server.
protected  void printTracks()
          Prints out the tracks that are currently played.
 void readParams(java.lang.String command, java.util.StringTokenizer st)
          Handles parameters belonging to some commands.
 void run()
          A loop that waits for commands from the console and when they arrive calls the correct method for them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s

private Server s
Constructor Detail

ServerCommandHandler

public ServerCommandHandler(Server srv)
Constructor.

Parameters:
srv - Server whose commands we are handling
Method Detail

run

public void run()
A loop that waits for commands from the console and when they arrive calls the correct method for them.

To exit the loop and close the server, command "exit" should be used.


readParams

public void readParams(java.lang.String command,
                       java.util.StringTokenizer st)
Handles parameters belonging to some commands.

Parameters:
command - the given command
st - StringTokenizer to read the parameters

printHelp

protected void printHelp()
Prints out helpful text.


printPlayers

protected void printPlayers()
Prints out the players currently connected to the server.


printTracks

protected void printTracks()
Prints out the tracks that are currently played.


kickAll

protected void kickAll()
Kicks all the players out from the server.


kickPlayer

protected void kickPlayer(int id)
Kicks the given player out from the server.

Parameters:
id - id of the player to kick out