Package org.zeromq
Class ZBeacon
- java.lang.Object
-
- org.zeromq.ZBeacon
-
public class ZBeacon extends java.lang.ObjectThis class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classZBeacon.BroadcastClientThe broadcast client periodically sends beacons via UDP to the network.private classZBeacon.BroadcastServerThe broadcast server receives beacons.static classZBeacon.Builderstatic interfaceZBeacon.ListenerAll beacons with matching prefix are passed to a listener.
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<byte[]>beaconprivate ZBeacon.BroadcastClientbroadcastClientprivate java.util.concurrent.atomic.AtomicLongbroadcastIntervalprivate ZBeacon.BroadcastServerbroadcastServerprivate java.util.concurrent.atomic.AtomicReference<java.lang.Thread.UncaughtExceptionHandler>clientExHandlerprivate static java.net.InetAddressDEFAULT_BROADCAST_ADDRESSstatic java.lang.StringDEFAULT_BROADCAST_HOSTprivate static java.net.InetAddressDEFAULT_BROADCAST_HOST_ADDRESSstatic longDEFAULT_BROADCAST_INTERVALprivate java.util.concurrent.atomic.AtomicReference<ZBeacon.Listener>listenerprivate java.util.concurrent.atomic.AtomicReference<byte[]>prefixprivate java.util.concurrent.atomic.AtomicReference<java.lang.Thread.UncaughtExceptionHandler>serverExHandler
-
Constructor Summary
Constructors Constructor Description ZBeacon(int port, byte[] beacon)ZBeacon(java.lang.String broadcastAddress, byte[] serverAddress, int port, byte[] beacon, long broadcastInterval, boolean ignoreLocalAddress, boolean blocking)Deprecated.ZBeacon(java.lang.String host, int port, byte[] beacon)ZBeacon(java.lang.String host, int port, byte[] beacon, boolean ignoreLocalAddress)ZBeacon(java.lang.String host, int port, byte[] beacon, boolean ignoreLocalAddress, boolean blocking)ZBeacon(java.net.InetAddress broadcastAddress, java.net.InetAddress serverAddress, int port, byte[] beacon, long broadcastInterval, boolean ignoreLocalAddress, boolean blocking)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]getBeacon()longgetBroadcastInterval()ZBeacon.ListenergetListener()byte[]getPrefix()voidsetBeacon(byte[] beacon)Deprecated.use the buildervoidsetBroadcastInterval(long broadcastInterval)voidsetListener(ZBeacon.Listener listener)Deprecated.use the buildervoidsetPrefix(byte[] prefix)Deprecated.use the buildervoidsetUncaughtExceptionHandlers(java.lang.Thread.UncaughtExceptionHandler clientExHandler, java.lang.Thread.UncaughtExceptionHandler serverExHandler)Deprecated.use the buildervoidstart()voidstartClient()voidstartServer()voidstop()
-
-
-
Field Detail
-
DEFAULT_BROADCAST_INTERVAL
public static final long DEFAULT_BROADCAST_INTERVAL
- See Also:
- Constant Field Values
-
DEFAULT_BROADCAST_HOST
public static final java.lang.String DEFAULT_BROADCAST_HOST
- See Also:
- Constant Field Values
-
DEFAULT_BROADCAST_HOST_ADDRESS
private static final java.net.InetAddress DEFAULT_BROADCAST_HOST_ADDRESS
-
DEFAULT_BROADCAST_ADDRESS
private static final java.net.InetAddress DEFAULT_BROADCAST_ADDRESS
-
broadcastClient
private final ZBeacon.BroadcastClient broadcastClient
-
broadcastServer
private final ZBeacon.BroadcastServer broadcastServer
-
prefix
private final java.util.concurrent.atomic.AtomicReference<byte[]> prefix
-
beacon
private final java.util.concurrent.atomic.AtomicReference<byte[]> beacon
-
broadcastInterval
private final java.util.concurrent.atomic.AtomicLong broadcastInterval
-
listener
private final java.util.concurrent.atomic.AtomicReference<ZBeacon.Listener> listener
-
clientExHandler
private final java.util.concurrent.atomic.AtomicReference<java.lang.Thread.UncaughtExceptionHandler> clientExHandler
-
serverExHandler
private final java.util.concurrent.atomic.AtomicReference<java.lang.Thread.UncaughtExceptionHandler> serverExHandler
-
-
Constructor Detail
-
ZBeacon
public ZBeacon(int port, byte[] beacon)
-
ZBeacon
public ZBeacon(java.lang.String host, int port, byte[] beacon)
-
ZBeacon
public ZBeacon(java.lang.String host, int port, byte[] beacon, boolean ignoreLocalAddress)
-
ZBeacon
public ZBeacon(java.lang.String host, int port, byte[] beacon, boolean ignoreLocalAddress, boolean blocking)
-
ZBeacon
public ZBeacon(java.net.InetAddress broadcastAddress, java.net.InetAddress serverAddress, int port, byte[] beacon, long broadcastInterval, boolean ignoreLocalAddress, boolean blocking)
-
ZBeacon
@Deprecated public ZBeacon(java.lang.String broadcastAddress, byte[] serverAddress, int port, byte[] beacon, long broadcastInterval, boolean ignoreLocalAddress, boolean blocking)Deprecated.
-
-
Method Detail
-
setUncaughtExceptionHandlers
@Deprecated public void setUncaughtExceptionHandlers(java.lang.Thread.UncaughtExceptionHandler clientExHandler, java.lang.Thread.UncaughtExceptionHandler serverExHandler)Deprecated.use the builder- Parameters:
clientExHandler-serverExHandler-
-
startClient
public void startClient()
-
startServer
public void startServer()
-
start
public void start()
-
stop
public void stop() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
setBeacon
@Deprecated public void setBeacon(byte[] beacon)
Deprecated.use the builder- Parameters:
beacon-
-
getBeacon
public byte[] getBeacon()
-
setPrefix
@Deprecated public void setPrefix(byte[] prefix)
Deprecated.use the builder- Parameters:
prefix-
-
getPrefix
public byte[] getPrefix()
-
setListener
@Deprecated public void setListener(ZBeacon.Listener listener)
Deprecated.use the builder- Parameters:
listener-
-
getListener
public ZBeacon.Listener getListener()
-
getBroadcastInterval
public long getBroadcastInterval()
-
setBroadcastInterval
public void setBroadcastInterval(long broadcastInterval)
-
-