public abstract class Layer2Handler extends java.lang.Object implements BitListener
Constructor and Description |
---|
Layer2Handler()
Create an object, using "localhost" and DEFAULT_PORT, for the
IP host and TCP port that this object's BitHandler will connect to
(i.e., the LightSystem).
|
Layer2Handler(java.lang.String host,
int port)
Create an object, and create a BitHandler for it to use in the layer
below it.
|
Modifier and Type | Method and Description |
---|---|
void |
bitsReceived(BitHandler handler,
java.lang.String bits)
Called when the layer below receives bits successfully.
|
boolean |
dropReceivedFrame(Layer2Frame fr,
java.lang.String bits)
A default implementation that says we do not drop a received frame.
|
void |
send(Layer2Frame frame)
Given a frame, convert it to a string of bits and send it using the
BitHandler on layer 1 "below".
|
void |
setListener(Layer2Listener l)
Allow another object (e.g., a Layer 3 object) to register itself to
get called when this object receives a good frame.
|
public Layer2Handler()
public Layer2Handler(java.lang.String host, int port)
public void send(Layer2Frame frame)
public void setListener(Layer2Listener l)
public boolean dropReceivedFrame(Layer2Frame fr, java.lang.String bits)
public void bitsReceived(BitHandler handler, java.lang.String bits)
bitsReceived
in interface BitListener