breakout
Class StudentConnector

java.lang.Object
  |
  +--breakout.StudentConnector
All Implemented Interfaces:
Connector, Runnable, WorldListener

public class StudentConnector
extends Object
implements Connector, WorldListener, Runnable

class StudentConnector is a possibly student-written class that implements the connection between the local breakout game and the partner's breakout game.

See Also:
World, NetworkSettings, WorldListener

Constructor Summary
StudentConnector(World local, World remote, NetworkSettings settings)
           
 
Method Summary
 void ballLeft(WorldEvent event)
          invoked when a ball leaves the world for another.
 void componentAdded(WorldEvent event)
          invoked when a component is added to the world.
 void componentRemoved(WorldEvent event)
          invoked when a component is removed from the world.
 void connect()
          The connector implementation should attempt to connect to the other party.
 boolean isConnected()
          returns true if the connector is connected to the partner game.
 void run()
          reads WorldEvents off the network and adds or removes components as directed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StudentConnector

public StudentConnector(World local,
                        World remote,
                        NetworkSettings settings)
Method Detail

componentAdded

public void componentAdded(WorldEvent event)
Description copied from interface: WorldListener
invoked when a component is added to the world. The event gives basic details about the component.

Specified by:
componentAdded in interface WorldListener
Parameters:
event - contains basic details of component that was added.

componentRemoved

public void componentRemoved(WorldEvent event)
Description copied from interface: WorldListener
invoked when a component is removed from the world. The event gives basic details about the component.

Specified by:
componentRemoved in interface WorldListener
Parameters:
event - contains basic details of component that was added.

ballLeft

public void ballLeft(WorldEvent event)
Description copied from interface: WorldListener
invoked when a ball leaves the world for another. The event describes the ball that just left.

Specified by:
ballLeft in interface WorldListener
Parameters:
event - contains basic details of ball that left.

run

public void run()
reads WorldEvents off the network and adds or removes components as directed.

Specified by:
run in interface Runnable

connect

public void connect()
Description copied from interface: Connector
The connector implementation should attempt to connect to the other party. No exceptions should be thrown, but isConnected should continue to return false in the case of failure. Calling connect() while already connected should do nothing.

Specified by:
connect in interface Connector

isConnected

public boolean isConnected()
Description copied from interface: Connector
returns true if the connector is connected to the partner game.

Specified by:
isConnected in interface Connector
Returns:
true if connected.