Class OutNetMessage

  • All Implemented Interfaces:
    CDPQEntry, CDQEntry, PQEntry

    public class OutNetMessage
    extends Object
    implements CDPQEntry
    Wrap up an outbound I2NP message, along with the information associated with its delivery and jobs to be fired off if particular events occur.
    • Constructor Detail

      • OutNetMessage

        public OutNetMessage​(RouterContext context)
        Null msg and target, zero expiration (used in OutboundMessageRegistry only)
        Since:
        0.9.9
      • OutNetMessage

        public OutNetMessage​(RouterContext context,
                             I2NPMessage msg,
                             long expiration,
                             int priority,
                             RouterInfo target)
        Standard constructor
        Parameters:
        msg - generally non-null
        target - generally non-null
        Since:
        0.9.9
    • Method Detail

      • timestamp

        public void timestamp​(String eventName)
        Stamp the message's progress. Only useful if log level is INFO or DEBUG
        Parameters:
        eventName - what occurred
      • getTarget

        public RouterInfo getTarget()
        Specifies the router to which the message should be delivered. Generally non-null but may be null in special cases.
      • getMessage

        public I2NPMessage getMessage()
        Specifies the message to be sent. Generally non-null but may be null in special cases.
      • getMessageType

        public String getMessageType()
        For debugging only.
        Returns:
        the simple class name
      • getMessageTypeId

        public int getMessageTypeId()
      • getMessageId

        public long getMessageId()
      • getMessageSize

        public int getMessageSize()
        How large the message is, including the full 16 byte header. Transports with different header sizes should adjust.
      • getMessageData

        public int getMessageData​(byte[] outBuffer)
        Copies the message data to outbuffer. Used only by VM Comm System.
        Returns:
        the length, or -1 if message is null
      • getPriority

        public int getPriority()
        Specify the priority of the message, where higher numbers are higher priority. Higher priority messages should be delivered before lower priority ones, though some algorithm may be used to avoid starvation.
        Specified by:
        getPriority in interface PQEntry
      • getExpiration

        public long getExpiration()
        Specify the # ms since the epoch after which if the message has not been sent the OnFailedSend job should be fired and the message should be removed from the pool. If the message has already been sent, this expiration is ignored and the expiration from the ReplySelector is used.
      • getOnSendJob

        public Job getOnSendJob()
        After the message is successfully passed to the router specified, the given job is enqueued.
      • setOnSendJob

        public void setOnSendJob​(Job job)
      • getOnFailedSendJob

        public Job getOnFailedSendJob()
        If the router could not be reached or the expiration passed, this job is enqueued.
      • setOnFailedSendJob

        public void setOnFailedSendJob​(Job job)
      • getOnReplyJob

        public ReplyJob getOnReplyJob()
        If the MessageSelector detects a reply, this job is enqueued
      • setOnReplyJob

        public void setOnReplyJob​(ReplyJob job)
      • getOnFailedReplyJob

        public Job getOnFailedReplyJob()
        If the Message selector is specified but it doesn't find a reply before its expiration passes, this job is enqueued.
      • setOnFailedReplyJob

        public void setOnFailedReplyJob​(Job job)
      • getReplySelector

        public MessageSelector getReplySelector()
        Defines a MessageSelector to find a reply to this message.
      • setReplySelector

        public void setReplySelector​(MessageSelector selector)
      • transportFailed

        public void transportFailed​(String transportStyle)
      • getFailedTransports

        public Set<String> getFailedTransports()
      • getSendBegin

        public long getSendBegin()
        when did the sending process begin
      • beginSend

        public void beginSend()
      • getCreated

        public long getCreated()
      • getLifetime

        public long getLifetime()
        time since the message was created
      • getSendTime

        public long getSendTime()
        time the transport tries to send the message (including any queueing)
      • setEnqueueTime

        public void setEnqueueTime​(long now)
        For CDQ
        Specified by:
        setEnqueueTime in interface CDQEntry
        Since:
        0.9.3
      • getEnqueueTime

        public long getEnqueueTime()
        For CDQ
        Specified by:
        getEnqueueTime in interface CDQEntry
        Since:
        0.9.3
      • drop

        public void drop()
        For CDQ
        Specified by:
        drop in interface CDQEntry
        Since:
        0.9.3
      • setSeqNum

        public void setSeqNum​(long num)
        For CDPQ
        Specified by:
        setSeqNum in interface PQEntry
        Since:
        0.9.3
      • getSeqNum

        public long getSeqNum()
        For CDPQ
        Specified by:
        getSeqNum in interface PQEntry
        Since:
        0.9.3
      • discardData

        public void discardData()
        We've done what we need to do with the data from this message, though we may keep the object around for a while to use its ID, jobs, etc.