gecco.communication.server
Class NewClientListener

java.lang.Object
  |
  +--gecco.communication.server.NewClientListener
All Implemented Interfaces:
Runnable

class NewClientListener
extends Object
implements Runnable

A class that will listen for incoming connections from clients, and handle the initial communication, until the client successfully joins as a role, and calls startGame. all communication with the client will thereafter be handled by a DataExchangeHandler

Author:
Niklas Hallenfur, Jon Åslund

Field Summary
private  DataInputStream data_in
          Description of the Field
private  DataOutputStream data_out
          Description of the Field
private  ServerSocket server
          Description of the Field
private  ClientAmbassador started_by
          Description of the Field
 
Constructor Summary
NewClientListener(ClientAmbassador s, int port)
           
 
Method Summary
 Socket accept()
          Description of the Method
private  boolean connectToKrigsspel(Socket s, String role)
          to be modified in iteration 2
 void run()
          to be removed in iteration 2
private  void sendAvailableRoles(Socket s)
          Description of the Method
 void sendMap()
          sends the whole map
 void sendMapSize()
          sends the size of the map
private  void startGame(Socket s, String role)
          Description of the Method
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

data_in

private DataInputStream data_in
Description of the Field

data_out

private DataOutputStream data_out
Description of the Field

started_by

private ClientAmbassador started_by
Description of the Field

server

private ServerSocket server
Description of the Field
Constructor Detail

NewClientListener

public NewClientListener(ClientAmbassador s,
                         int port)
                  throws IOException
Parameters:
port - The port where to listen for incoming connections
s - Description of Parameter
Throws:
IOException - Description of Exception
Method Detail

run

public void run()
to be removed in iteration 2
Specified by:
run in interface Runnable

accept

public Socket accept()
Description of the Method
Returns:
Description of the Returned Value

sendMapSize

public void sendMapSize()
                 throws Exception
sends the size of the map
Throws:
Exception - Description of Exception

sendMap

public void sendMap()
             throws Exception
sends the whole map
Throws:
Exception - Description of Exception

sendAvailableRoles

private void sendAvailableRoles(Socket s)
                         throws Exception
Description of the Method
Parameters:
s - Description of Parameter
Throws:
Exception - Description of Exception

connectToKrigsspel

private boolean connectToKrigsspel(Socket s,
                                   String role)
to be modified in iteration 2
Parameters:
s - Description of Parameter
role - Description of Parameter
Returns:
Description of the Returned Value

startGame

private void startGame(Socket s,
                       String role)
Description of the Method
Parameters:
s - Description of Parameter
role - Description of Parameter