glassfrog.server
Class Room.RoomConnectionHandler

java.lang.Object
  extended by glassfrog.server.Room.RoomConnectionHandler
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
Room

private class Room.RoomConnectionHandler
extends java.lang.Object
implements java.lang.Runnable

An Inner Class used to handle incoming connections to the room. These connections should be player connections, and each type of player will have thier own way to connect depending on the type of player.


Field Summary
private  java.io.BufferedReader br
           
private  java.lang.String connectionArgs
           
private  java.io.PrintWriter pw
           
private  java.net.Socket socket
           
 
Constructor Summary
Room.RoomConnectionHandler(java.net.Socket socket)
          The constructor for the ConnectionHandler inner class.
 
Method Summary
private  void addPlayer(Player newPlayer)
          Check to see if the name and the seat are already assigned to a player if so, use the next open seat or assign a random int between 1 and 10 to the player name
private  void cleanup(boolean stillAlive)
           
 void run()
          This method handles the request sent in on the socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionArgs

private java.lang.String connectionArgs

socket

private java.net.Socket socket

pw

private java.io.PrintWriter pw

br

private java.io.BufferedReader br
Constructor Detail

Room.RoomConnectionHandler

public Room.RoomConnectionHandler(java.net.Socket socket)
                           throws java.io.IOException
The constructor for the ConnectionHandler inner class. The connection handler takes a socket passed in from the room, opens a print writer and buffered reader on the socket and then parses the first argument sent by the connection. The connections should be players connections or commands send by the server

Parameters:
socket - A socket passed in to handle the connection in and outputs
Throws:
java.io.IOException
Method Detail

run

public void run()
This method handles the request sent in on the socket. If the request is of the player type, then handlePlayerRequest is called. If the request is of the server type, then the handleServerRequest is called.

Specified by:
run in interface java.lang.Runnable

addPlayer

private void addPlayer(Player newPlayer)
Check to see if the name and the seat are already assigned to a player if so, use the next open seat or assign a random int between 1 and 10 to the player name

Parameters:
newPlayer - The player to ba added to the players list

cleanup

private void cleanup(boolean stillAlive)