spellcast.client
Class ClientConnectionHandler

java.lang.Object
  extended by spellcast.client.ClientConnectionHandler
All Implemented Interfaces:
java.lang.Runnable

public class ClientConnectionHandler
extends java.lang.Object
implements java.lang.Runnable

This class handles the socket functions for the client.

Author:
Barrie Treloar

Constructor Summary
ClientConnectionHandler(SpellcastView view, VersionDetails programVersionDetails)
           
 
Method Summary
 void connect(java.lang.String serverAddressString, java.lang.String wizardName, java.lang.String gender)
          Request connection to the specified address and port.
 void disconnect()
          Request the network controller to disconnect from the existing connection.
 void join()
          Waits for the socket handler thread to complete.
 GameEvent receive()
          Removes the first event from the incoming event queue and returns it.
 void run()
           
 void send(GameEvent event)
          Send the event to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientConnectionHandler

public ClientConnectionHandler(SpellcastView view,
                               VersionDetails programVersionDetails)
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

receive

public GameEvent receive()
Removes the first event from the incoming event queue and returns it. If there are no events in the queue this will wait until one is added when the server sends the client an event, at which point the thread will be notified.

If there is an IOException cleanup may call notify in which case the event will be null.


send

public void send(GameEvent event)
Send the event to the server.


connect

public void connect(java.lang.String serverAddressString,
                    java.lang.String wizardName,
                    java.lang.String gender)
Request connection to the specified address and port.

Parameters:
serverAddressString - a server string of the form host[:port]
wizardName - the name of the client's wizard
gender - the gender of the client's wizard

disconnect

public void disconnect()
Request the network controller to disconnect from the existing connection.


join

public void join()
Waits for the socket handler thread to complete.



Copyright © 2001-2005 Spellcast. All Rights Reserved.