Class MulticastReceiver
- java.lang.Object
-
- org.appng.core.controller.messaging.MulticastReceiver
-
-
Constructor Summary
Constructors Constructor Description MulticastReceiver()
MulticastReceiver(String address, Integer port)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the receiver, in particular blocking I/O resources need to be closed here.MulticastReceiver
configure(Serializer eventSerializer)
Configures the receiverSender
createSender()
protected String
getGroupAddress()
protected Integer
getGroupPort()
protected boolean
isSameAddress(String hostAddress)
void
registerHandler(EventHandler<?> handler)
Registers a newEventHandler
void
run()
void
runWith(ExecutorService executorService)
Since a receiver runs as a thread, the givenExecutorService
should be used to run this thread.void
setDefaultHandler(EventHandler<?> defaultHandler)
Sets the defaultEventHandler
, used when no other handler is registered for a certain event typeprotected void
setGroupAddress(String address)
protected void
setGroupPort(Integer port)
-
-
-
Method Detail
-
configure
public MulticastReceiver configure(Serializer eventSerializer)
Description copied from interface:Receiver
Configures the receiver- Specified by:
configure
in interfaceReceiver
- Parameters:
eventSerializer
- theSerializer
for this receiver- Returns:
- the configured receiver
-
runWith
public void runWith(ExecutorService executorService)
Description copied from interface:Receiver
Since a receiver runs as a thread, the givenExecutorService
should be used to run this thread.- Specified by:
runWith
in interfaceReceiver
- Parameters:
executorService
- theExecutorService
to run this receiver with
-
createSender
public Sender createSender()
Description copied from interface:Receiver
Creates and returns aSender
capable of sendingEvent
s that can be received by this type of receiver.- Specified by:
createSender
in interfaceReceiver
- Returns:
- the
Sender
-
registerHandler
public void registerHandler(EventHandler<?> handler)
Description copied from interface:Receiver
Registers a newEventHandler
- Specified by:
registerHandler
in interfaceReceiver
- Parameters:
handler
- theEventHandler
to register
-
setDefaultHandler
public void setDefaultHandler(EventHandler<?> defaultHandler)
Description copied from interface:Receiver
Sets the defaultEventHandler
, used when no other handler is registered for a certain event type- Specified by:
setDefaultHandler
in interfaceReceiver
- Parameters:
defaultHandler
- the defaultEventHandler
to use
-
close
public void close() throws IOException
Description copied from interface:Receiver
Closes the receiver, in particular blocking I/O resources need to be closed here.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceReceiver
- Throws:
IOException
-
getGroupPort
protected Integer getGroupPort()
-
getGroupAddress
protected String getGroupAddress()
-
setGroupPort
protected void setGroupPort(Integer port)
-
setGroupAddress
protected void setGroupAddress(String address)
-
isSameAddress
protected boolean isSameAddress(String hostAddress) throws UnknownHostException, SocketException
- Throws:
UnknownHostException
SocketException
-
-