public interface IBlaubotConnectionAcceptor
IBlaubotListeningStateListener
.
A connection is successfully established, if the the connection could be accepted and the
client send his state but more importantly his connection meta data via a BeaconMessage through
the just established connection.
The received BeaconMessage MUST then be wrapped in a AbstractBlaubotDiscoveryEvent and be
populated to the BeaconStore, in case the just connected client will be pronounced prince and
the other peasants have to know the connection meta data.
This is crucial because if a client connected to the king without being discovered via a beacon
before, the king lacks the connection info which has to be send to his peasants in case he
dies.
Note that the BeaconMessage already has helper methods to send and receive itself through a
IBlaubotConnection and there is not really much to be hand written on that behalf.
If a client successfully established a connection it will then be populated through the
registered IBlaubotIncomingConnectionListener
.Modifier and Type | Method and Description |
---|---|
IBlaubotAdapter |
getAdapter()
Get the adapter of which this acceptor is part of.
|
ConnectionMetaDataDTO |
getConnectionMetaData()
Get the connection meta data needed to connect to this connector
This infos can range from mac addresses over ip addresses to port numbers.
|
boolean |
isStarted()
Retrieves the started state of this acceptor.
|
void |
setAcceptorListener(IBlaubotIncomingConnectionListener acceptorListener)
Sets a listener that receives callbacks whenever a connection was accepted by the acceptor.
|
void |
setBeaconStore(IBlaubotBeaconStore beaconStore)
Dependency injecton for the BeaconStore.
|
void |
setListeningStateListener(IBlaubotListeningStateListener stateListener)
Sets a listener that receives callbacks, when the acceptor started accepting connections (is listening).
|
void |
startListening()
Starts the connection acceptor.
|
void |
stopListening()
Stops a running acceptor.
|
void setBeaconStore(IBlaubotBeaconStore beaconStore)
beaconStore
- the beaconStoreIBlaubotAdapter getAdapter()
void startListening()
void stopListening()
boolean isStarted()
void setListeningStateListener(IBlaubotListeningStateListener stateListener)
stateListener
- the listner to setvoid setAcceptorListener(IBlaubotIncomingConnectionListener acceptorListener)
acceptorListener
- the listener to be setConnectionMetaDataDTO getConnectionMetaData()