All Known Implementing Classes:
FloodfillVerifyStoreJob.VerifyReplySelector, FloodOnlyLookupSelector, IterativeLookupSelector, OutboundClientMessageOneShotJob.ReplySelector, PeerTestJob.ReplySelector, SearchMessageSelector, StoreMessageSelector, TestJob.ReplySelector

public interface MessageSelector
Define a mechanism to select what messages are associated with a particular OutNetMessage. This is used for finding replies to messages.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    boolean
    Returns true if the selector should still keep searching for further matches.
    long
    Returns the # of milliseconds since the epoch after which this selector should stop searching for matches.
    boolean
    Returns true if the received message matches the selector.
  • Method Details

    • isMatch

      boolean isMatch(I2NPMessage message)
      Returns true if the received message matches the selector. If this returns true, the job specified by OutNetMessage.getOnReplyJob() will be run for every OutNetMessage associated with this selector (by InNetMessagePool), after calling setMessage() for that ReplyJob.

      WARNING this is called from within OutboundMessageSelector.getOriginalMessages() inside a lock and can lead to deadlocks if the selector does too much in isMatch(I2NPMessage). Until the lock is removed, take care to keep it simple.

      Parameters:
      message - the received message to test against this selector
      Returns:
      true if the received message is one this selector was waiting for
    • continueMatching

      boolean continueMatching()
      Returns true if the selector should still keep searching for further matches. This is called only if isMatch() returns true. If this returns true, isMatch() will not be called again.
      Returns:
      true to keep searching for further matches, false to stop searching
    • getExpiration

      long getExpiration()
      Returns the # of milliseconds since the epoch after which this selector should stop searching for matches. At some time after expiration, if continueMatching() has not returned false, the job specified by OutNetMessage.getOnFailedReplyJob() will be run for every OutNetMessage associated with this selector (by OutboundMessageRegistry).
      Returns:
      the number of milliseconds since the epoch at which to stop searching