vooga.network
Class VoogaClient

java.lang.Object
  extended by vooga.network.VoogaClient
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
VoogaChatClient, VoogaGameClient, VoogaLobbyClient, VoogaUtilsClient

public abstract class VoogaClient
extends java.lang.Object
implements java.lang.Runnable

VoogaClient is the superclass for all client classes in vooga, handling behavior that is shared across the multiple clients such as the specifics of connecting to a server.

Author:
tgr3, tws10, sam1

Constructor Summary
VoogaClient()
           
VoogaClient(java.lang.String name)
           
 
Method Summary
static void allowConnection()
          Invoking this method will allow any subclass of VoogaClient from connection to the server.
static void blockConnection()
          Invoking this method will prevent any subclass of VoogaClient from connection from the server until allowConnection() is called.
 void connect()
          Connects to the server defined in the properties file by IP address.
abstract  void connect(java.net.InetAddress host)
          Connects to the server at the specified address.
 void connect(java.net.InetAddress host, int port)
          Connects to the given port of the named host
 void disconnect()
          Disconnects from the server.
protected  java.io.ObjectInputStream getMyInputStream()
           
protected  java.lang.String getMyName()
           
protected  java.io.ObjectOutputStream getMyOutputStream()
           
protected  java.net.Socket getMySocket()
           
protected abstract  void initializeConnection()
          Performs any necessary set-up for a new connection.
 boolean isConnected()
           
protected  void setConnected(boolean connected)
           
protected  void setMyName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

VoogaClient

public VoogaClient()

VoogaClient

public VoogaClient(java.lang.String name)
Method Detail

getMySocket

protected java.net.Socket getMySocket()

getMyName

protected java.lang.String getMyName()

setMyName

protected void setMyName(java.lang.String name)

getMyInputStream

protected java.io.ObjectInputStream getMyInputStream()
                                              throws java.io.IOException
Throws:
java.io.IOException

getMyOutputStream

protected java.io.ObjectOutputStream getMyOutputStream()
                                                throws java.io.IOException
Throws:
java.io.IOException

isConnected

public boolean isConnected()

setConnected

protected void setConnected(boolean connected)

connect

public void connect()
             throws java.io.FileNotFoundException,
                    java.io.IOException
Connects to the server defined in the properties file by IP address.

Throws:
java.io.IOException
java.io.FileNotFoundException

connect

public abstract void connect(java.net.InetAddress host)
                      throws java.io.IOException
Connects to the server at the specified address. The implementation of this method in each of the client subclasses should call the connect method with the given host and the port number specific to that client.

Parameters:
host - The IP of an existing VoogaChatServer.
Throws:
java.io.IOException

connect

public void connect(java.net.InetAddress host,
                    int port)
             throws java.io.IOException
Connects to the given port of the named host

Parameters:
host -
port -
Throws:
java.io.IOException

disconnect

public void disconnect()
                throws java.io.IOException
Disconnects from the server.

Throws:
java.io.IOException

blockConnection

public static void blockConnection()
Invoking this method will prevent any subclass of VoogaClient from connection from the server until allowConnection() is called.


allowConnection

public static void allowConnection()
Invoking this method will allow any subclass of VoogaClient from connection to the server.


initializeConnection

protected abstract void initializeConnection()
Performs any necessary set-up for a new connection.