x10.net
Class SocketController

java.lang.Object
  extended byx10.net.SocketController
All Implemented Interfaces:
Controller, java.lang.Runnable

public class SocketController
extends java.lang.Object
implements java.lang.Runnable, Controller

SocketController is a Client-side virtual Controller object that connects to a ControllerServer via TCP socket.


Constructor Summary
SocketController(java.lang.String host, int port)
          SocketController constructs a SocketController that automatically connects to the ControllerServer on the specified host and port.
 
Method Summary
 void addCommand(Command command)
          addCommand adds a Command to be queued and then dispatched to the ControllerServer
 void addUnitListener(UnitListener listener)
          addUnitListener registers the specified UnitListener to recieve UnitEvents
 void removeUnitListener(UnitListener listener)
          removeUnitListener unregisters the specified UnitListener.
 void run()
          run loops receiving events from the ControllerServer and then dispatching the events to locally registered UnitListeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketController

public SocketController(java.lang.String host,
                        int port)
                 throws java.io.IOException,
                        java.net.SocketException
SocketController constructs a SocketController that automatically connects to the ControllerServer on the specified host and port.

Parameters:
host - the hostname or IP address of the server that is hosting the ControllerServer.
port - the port that the ControllerServer is listening on.
Throws:
java.io.IOException - thrown if an error occurs setting up the streams to/from the ControllerServer
java.net.SocketException - thrown if an error occurs connecting to the ControllerServer
Method Detail

addUnitListener

public void addUnitListener(UnitListener listener)
addUnitListener registers the specified UnitListener to recieve UnitEvents

Specified by:
addUnitListener in interface Controller
Parameters:
listener - the listener to register
See Also:
UnitEvent

removeUnitListener

public void removeUnitListener(UnitListener listener)
removeUnitListener unregisters the specified UnitListener.

Specified by:
removeUnitListener in interface Controller
Parameters:
listener - the listener to remove.

addCommand

public void addCommand(Command command)
addCommand adds a Command to be queued and then dispatched to the ControllerServer

Specified by:
addCommand in interface Controller
Parameters:
command - the Command to be queued.

run

public void run()
run loops receiving events from the ControllerServer and then dispatching the events to locally registered UnitListeners.

Specified by:
run in interface java.lang.Runnable


Copyright ©2000-2005 Wade Wassenberg.
On the web: http://x10.homelinux.org.
Send bug reports to x10@wass.homelinux.net.
Last Modified June 1, 2005