server
Class Server

java.lang.Object
  extended by server.Server

public class Server
extends java.lang.Object


Constructor Summary
Server()
           
 
Method Summary
static void createNewUser(NetworkObject n, ServerThread s)
          Creates a new user account.
static java.lang.String getPlayerRecords(java.lang.String name, java.lang.String game)
          Returns a String representation of the Player and his record associated with this thread.
static void getRankings(ServerThread player)
          Sends the overall ranking of players (by most wins) to the player that requested it.
static void getRankings(java.lang.String game, ServerThread player)
          Sends an array of Strings containing a list of the top 10 players and their records for the given game.
static void logoutPlayer(java.lang.String name)
          Makes a note in the database that this player is no longer logged in.
static void main(java.lang.String[] args)
          The main method of the program.
static void passMessage(NetworkObject n, int tableNum, int playerNum)
          Passes the message to the Table that the player is sitting at.
static void removeFromIdle(ServerThread player)
          Removes the specified player from the idle Vector due to a disconnect.
static void removeFromTable(ServerThread player, int tableID)
          Removes the specified player from the ServerThread representing that player.
static void selectGame(NetworkObject n, ServerThread s)
          Places the ServerThread from the idle Vector to the appropriate Table.
static void updatePlayerRecords(java.lang.String name, java.lang.String game, java.lang.String result)
          Updates a particular player's record for the specified game with the specified result.
static void validateLogin(NetworkObject n, ServerThread s)
          Validates a user's login info.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Server

public Server()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
The main method of the program. Listens for and accepts new connections to clients.

Parameters:
args - String[]
Throws:
java.io.IOException

getPlayerRecords

public static java.lang.String getPlayerRecords(java.lang.String name,
                                                java.lang.String game)
Returns a String representation of the Player and his record associated with this thread.

Parameters:
name - String of the player whose records need to be retrieved.
game - String found in Game defines the game of which the records need to be retrieved.
Returns:
String representation of the Player and his record associated with this thread.

updatePlayerRecords

public static void updatePlayerRecords(java.lang.String name,
                                       java.lang.String game,
                                       java.lang.String result)
Updates a particular player's record for the specified game with the specified result.

Parameters:
name - String of the player.
game - String for which the records need to be udpated.
result - String either Wins, Draws, or Losses.

validateLogin

public static void validateLogin(NetworkObject n,
                                 ServerThread s)
Validates a user's login info.

Parameters:
n - NetworkObject contains the login info.
s - ServerThread that just received the message.

logoutPlayer

public static void logoutPlayer(java.lang.String name)
Makes a note in the database that this player is no longer logged in.

Parameters:
name - String of the Player that logged out.

createNewUser

public static void createNewUser(NetworkObject n,
                                 ServerThread s)
Creates a new user account.

Parameters:
n - NetworkObject contains the login info
s - ServerThread that just received the message.

getRankings

public static void getRankings(ServerThread player)
Sends the overall ranking of players (by most wins) to the player that requested it.

Parameters:
player - ServerThread that requested the records.

getRankings

public static void getRankings(java.lang.String game,
                               ServerThread player)
Sends an array of Strings containing a list of the top 10 players and their records for the given game.

Parameters:
game - String for which the top 10 players need to be computed.
player - ServerThread is the player requesting the records. for the given game.

selectGame

public static void selectGame(NetworkObject n,
                              ServerThread s)
Places the ServerThread from the idle Vector to the appropriate Table. Creates a new Table if necessary.

Parameters:
n - NetworkObject
s - ServerThread

removeFromTable

public static void removeFromTable(ServerThread player,
                                   int tableID)
Removes the specified player from the ServerThread representing that player.

Parameters:
player - ServerThread representing the player that needs to be removed from the table.
tableID - int that the player is sitting at.

removeFromIdle

public static void removeFromIdle(ServerThread player)
Removes the specified player from the idle Vector due to a disconnect.

Parameters:
player - ServerThread

passMessage

public static void passMessage(NetworkObject n,
                               int tableNum,
                               int playerNum)
Passes the message to the Table that the player is sitting at.

Parameters:
n - NetworkObject that the player sent.
tableNum - int the table number that the player is sitting at.
playerNum - int the number of the player at the Table.