public abstract class AbstractMultiMessageSender extends Object implements MulticastMessageSender, MessageSender
MulticastMessageSender and MessageSender logic simply in order to
help the specific transport layer to be implemented easily
Mainly, this stores both source's PeerID and target's PeerID before sending the message to the peer
or broadcasting the message to all members| Modifier and Type | Field and Description |
|---|---|
protected PeerID |
localPeerID
Represents local
PeerID. |
TCP_TRANSPORT, UDP_TRANSPORT| Constructor and Description |
|---|
AbstractMultiMessageSender() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
broadcast(Message message)
Broadcasts or Multicasts the given
Message to all members |
protected abstract boolean |
doBroadcast(Message message)
Broadcasts or Multicasts the given
Message to all members |
protected abstract boolean |
doSend(PeerID peerID,
Message message)
Sends the given
Message to the destination |
boolean |
send(PeerID peerID,
Message message)
Sends the given
Message to the destination |
void |
start() |
void |
stop() |
protected PeerID localPeerID
PeerID. This value should be assigned in real MessageSender's implementation
correspoinding to the specific transport layerpublic boolean broadcast(Message message) throws IOException
Message to all membersbroadcast in interface MulticastMessageSendermessage - a message which is sent to all membersIOException - if I/O error occurs or given parameters are not validpublic boolean send(PeerID peerID, Message message) throws IOException
Message to the destinationsend in interface MessageSenderpeerID - the destination PeerID. null is not allowedmessage - a message which is sent to the peerIOException - if I/O error occurs or given parameters are not validpublic void start()
throws IOException
start in interface ShoalMessageSenderIOExceptionpublic void stop()
throws IOException
stop in interface ShoalMessageSenderIOExceptionprotected abstract boolean doBroadcast(Message message) throws IOException
Message to all membersmessage - a message which is sent to all membersIOException - if I/O error occurs or given parameters are not validprotected abstract boolean doSend(PeerID peerID, Message message) throws IOException
Message to the destinationpeerID - the destination PeerID. null is not allowedmessage - a message which is sent to the peerIOException - if I/O error occurs or given parameters are not validCopyright © 2017–2020 Eclipse Foundation. All rights reserved.