public class DiscoveringService
extends java.lang.Object
It uses a diffusion channel to publish the (local) peer identity (IP and port as String xx.xx.xx.xx:pppp). This publication is done in the "DiscoverWriteThread". The "DiscoverReadThread" reads the diffusion channel in order to know all peers in the party. New peers are notified to the associated MultiPeer by calling "addDestination".
The diffusion channel must be agreed by all peers in the party. In fact, it identifies the group. The associated MultiPeer and Diffusion Channel are provided to the DiscoveringService constructor.
The period of the "DiscoverWriteThread" is variable belonging to [periodDiffusionMAX..periodDiffusionMIN]. It is more frequent at startup time and it is reactive when a new peer is detected.
Both discovering threads are high-priority in order to configure the system as soon as possible.
Modifier and Type | Class and Description |
---|---|
private class |
DiscoveringService.DiscoverReadThread |
private class |
DiscoveringService.DiscoverWriteThread |
private class |
DiscoveringService.StaticPeersThread |
Modifier and Type | Field and Description |
---|---|
private boolean |
connected |
private java.net.InetAddress |
group |
private static int |
MAX_NET_TRIES |
private MultiPeer |
multiPeer |
private IPPort |
muticastIPPort |
private int |
newPeerDetectedCounter |
private int |
periodDiffusion |
private static int |
periodDiffusionMAX |
private static int |
periodDiffusionMIN |
private java.net.MulticastSocket |
socket |
Constructor and Description |
---|
DiscoveringService(MultiPeer mp,
IPPort ipp)
DiscoveringService constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isConnected() |
private void |
notifyIPPortReception(IPPort ipPort)
Used by "DiscoverReadThread" in order to notify the detection of a new peer.
|
private void |
startDiscoveringService()
Create the communications artifacts and starts the working threads
|
private void |
stopDiscoveringService()
Stop threads and close communication artifacts.
|
private void |
waitToNextLoop()
Used by the "DiscoverWriteThread" to control the execution period.
|
private boolean connected
private java.net.InetAddress group
private static int MAX_NET_TRIES
private MultiPeer multiPeer
private IPPort muticastIPPort
private int newPeerDetectedCounter
private int periodDiffusion
private static int periodDiffusionMAX
private static int periodDiffusionMIN
private java.net.MulticastSocket socket
public boolean isConnected()
private void notifyIPPortReception(IPPort ipPort)
private void startDiscoveringService()
private void stopDiscoveringService()
private void waitToNextLoop()