Class AbstractMultiMessageSender

    • Field Detail

      • localPeerID

        protected PeerID localPeerID
        Represents local PeerID. This value should be assigned in real MessageSender's implementation correspoinding to the specific transport layer
    • Constructor Detail

      • AbstractMultiMessageSender

        public AbstractMultiMessageSender()
    • Method Detail

      • broadcast

        public boolean broadcast​(Message message)
                          throws java.io.IOException
        Broadcasts or Multicasts the given Message to all members
        Specified by:
        broadcast in interface MulticastMessageSender
        Parameters:
        message - a message which is sent to all members
        Returns:
        true if the message is sent to all members successfully, otherwise false
        Throws:
        java.io.IOException - if I/O error occurs or given parameters are not valid
      • send

        public boolean send​(PeerID peerID,
                            Message message)
                     throws java.io.IOException
        Sends the given Message to the destination
        Specified by:
        send in interface MessageSender
        Parameters:
        peerID - the destination PeerID. null is not allowed
        message - a message which is sent to the peer
        Returns:
        true if the message is sent to the destination successfully, otherwise false
        Throws:
        java.io.IOException - if I/O error occurs or given parameters are not valid
      • start

        public void start()
                   throws java.io.IOException
        Specified by:
        start in interface ShoalMessageSender
        Throws:
        java.io.IOException
      • stop

        public void stop()
                  throws java.io.IOException
        Specified by:
        stop in interface ShoalMessageSender
        Throws:
        java.io.IOException
      • doBroadcast

        protected abstract boolean doBroadcast​(Message message)
                                        throws java.io.IOException
        Broadcasts or Multicasts the given Message to all members
        Parameters:
        message - a message which is sent to all members
        Returns:
        true if the message is sent to all members successfully, otherwise false
        Throws:
        java.io.IOException - if I/O error occurs or given parameters are not valid
      • doSend

        protected abstract boolean doSend​(PeerID peerID,
                                          Message message)
                                   throws java.io.IOException
        Sends the given Message to the destination
        Parameters:
        peerID - the destination PeerID. null is not allowed
        message - a message which is sent to the peer
        Returns:
        true if the message is sent to the destination successfully, otherwise false
        Throws:
        java.io.IOException - if I/O error occurs or given parameters are not valid