Class NetworkHandler

java.lang.Object
  |
  +--NetworkHandler
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener

public class NetworkHandler
extends java.lang.Object
implements java.beans.PropertyChangeListener

NetworkHandler handles the XMLSocket and executes network actions The NetworkHandler handles both the network messages as well as message construction and message parsing. It will send events to the GUI to draw as well as accepts commands from the GUI layer.


Field Summary
static java.net.InetAddress currentHost
          the host to connect to
static int currentPort
          the port to connect to
 
Method Summary
 void disconnect(Connection conn)
          disconnect from the Connection conn Fully Disconnect a Connection.
static java.net.InetAddress getCurrentHost()
          Get's the current Host
static int getCurrentPort()
          gets the current port
 void getLastUpdateTime()
          sends the get last update time message and returns value in a callback.
 void getLastUpdateTime(int lastTime)
          sends the get last update time message and returns value in a callback.
 void getView()
          sends the get last update time message and returns value in a callback.
 void messageHandle(XMLString value)
          MessagesHandler, handles XML messages.
static NetworkHandler networkHandler(ViewWindow view)
          Singleton, returns a network handler handling view.
 void patch(Connection connIn, Connection connOut)
          Sends Connector a message to patch the connection represented by "connect1" to the connection represented by "connect2".
 void propertyChange(java.beans.PropertyChangeEvent evt)
          propertyChange listener accepts messages from XMLSocket
static void setCurrentHost(java.net.InetAddress i)
          set the current host with address i
static void setCurrentPort(int i)
          set the current port with i
 void shutDown()
          sends the shutdown message to the server
 void unPatch(Connection connIn, Connection connOut)
          Unpatches and patch between connections "connect1" and "connect2"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentHost

public static java.net.InetAddress currentHost
the host to connect to


currentPort

public static int currentPort
the port to connect to

Method Detail

setCurrentHost

public static void setCurrentHost(java.net.InetAddress i)
set the current host with address i

Parameters:
i - the address of the host to connect to

setCurrentPort

public static void setCurrentPort(int i)
set the current port with i

Parameters:
i - the port of the host to connect to

getCurrentHost

public static java.net.InetAddress getCurrentHost()
Get's the current Host


getCurrentPort

public static int getCurrentPort()
gets the current port


networkHandler

public static NetworkHandler networkHandler(ViewWindow view)
Singleton, returns a network handler handling view.

Parameters:
view - the ViewWindow which recieves events from the NetworkHandler

disconnect

public void disconnect(Connection conn)
                throws java.io.IOException
disconnect from the Connection conn Fully Disconnect a Connection.

Parameters:
conn - the connection to disconnect
Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

unPatch

public void unPatch(Connection connIn,
                    Connection connOut)
             throws java.io.IOException
Unpatches and patch between connections "connect1" and "connect2"

Parameters:
connIn - the connection to unpatch From
connOut - the connection to unpatch To
Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

patch

public void patch(Connection connIn,
                  Connection connOut)
           throws java.io.IOException
Sends Connector a message to patch the connection represented by "connect1" to the connection represented by "connect2". "connect1" serves as an Input Connection while connect2 serves as an Output Connection.

Parameters:
connIn - the connection to patch From
connOut - the connection to patch To
Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

getLastUpdateTime

public void getLastUpdateTime()
                       throws java.io.IOException
sends the get last update time message and returns value in a callback.

Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

getLastUpdateTime

public void getLastUpdateTime(int lastTime)
                       throws java.io.IOException
sends the get last update time message and returns value in a callback.

Parameters:
lastTime - the lastTime we asked.
Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

getView

public void getView()
             throws java.io.IOException
sends the get last update time message and returns value in a callback.

Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange listener accepts messages from XMLSocket

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - the event

shutDown

public void shutDown()
              throws java.io.IOException
sends the shutdown message to the server

Throws:
java.io.IOException - if there is an IOException (e.g. can't send a message)

messageHandle

public void messageHandle(XMLString value)
MessagesHandler, handles XML messages.