Class PeerForeignNetworkConnection.omq

java.lang.Object
com.biglybt.pifimpl.local.peers.PeerForeignNetworkConnection.omq
All Implemented Interfaces:
OutgoingMessageQueue
Enclosing class:
PeerForeignNetworkConnection

protected class PeerForeignNetworkConnection.omq extends Object implements OutgoingMessageQueue
  • Constructor Details

    • omq

      protected omq()
  • Method Details

    • setTransport

      public void setTransport(Transport _transport)
      Specified by:
      setTransport in interface OutgoingMessageQueue
    • getMssSize

      public int getMssSize()
      Specified by:
      getMssSize in interface OutgoingMessageQueue
    • setEncoder

      public void setEncoder(MessageStreamEncoder stream_encoder)
      Description copied from interface: OutgoingMessageQueue
      Set the message stream encoder that will be used to encode outgoing messages.
      Specified by:
      setEncoder in interface OutgoingMessageQueue
      Parameters:
      stream_encoder - to use
    • getEncoder

      public MessageStreamEncoder getEncoder()
      Specified by:
      getEncoder in interface OutgoingMessageQueue
    • getCurrentMessageProgress

      public int[] getCurrentMessageProgress()
      Specified by:
      getCurrentMessageProgress in interface OutgoingMessageQueue
      Returns:
      [ total, done] or null
    • destroy

      public void destroy()
      Description copied from interface: OutgoingMessageQueue
      Destroy this queue; i.e. perform cleanup actions.
      Specified by:
      destroy in interface OutgoingMessageQueue
    • flush

      public void flush()
      Description copied from interface: OutgoingMessageQueue
      Force all pending messages to be delivered
      Specified by:
      flush in interface OutgoingMessageQueue
    • isDestroyed

      public boolean isDestroyed()
      Specified by:
      isDestroyed in interface OutgoingMessageQueue
    • getTotalSize

      public int getTotalSize()
      Description copied from interface: OutgoingMessageQueue
      Get the total number of bytes ready to be transported.
      Specified by:
      getTotalSize in interface OutgoingMessageQueue
      Returns:
      total bytes remaining
    • getDataQueuedBytes

      public int getDataQueuedBytes()
      Specified by:
      getDataQueuedBytes in interface OutgoingMessageQueue
    • getProtocolQueuedBytes

      public int getProtocolQueuedBytes()
      Specified by:
      getProtocolQueuedBytes in interface OutgoingMessageQueue
    • getPriorityBoost

      public boolean getPriorityBoost()
      Specified by:
      getPriorityBoost in interface OutgoingMessageQueue
    • setPriorityBoost

      public void setPriorityBoost(boolean boost)
      Specified by:
      setPriorityBoost in interface OutgoingMessageQueue
    • isBlocked

      public boolean isBlocked()
      Specified by:
      isBlocked in interface OutgoingMessageQueue
    • hasUrgentMessage

      public boolean hasUrgentMessage()
      Description copied from interface: OutgoingMessageQueue
      Whether or not an urgent message (one that needs an immediate send, i.e. a no-delay message) is queued.
      Specified by:
      hasUrgentMessage in interface OutgoingMessageQueue
      Returns:
      true if there's a message tagged for immediate write
    • peekFirstMessage

      public Message peekFirstMessage()
      Specified by:
      peekFirstMessage in interface OutgoingMessageQueue
    • addMessage

      public void addMessage(Message message, boolean manual_listener_notify)
      Description copied from interface: OutgoingMessageQueue
      Add a message to the message queue. NOTE: Allows for manual listener notification at some later time, using doListenerNotifications(), instead of notifying immediately from within this method. This is useful if you want to invoke listeners outside of some greater synchronised block to avoid deadlock.
      Specified by:
      addMessage in interface OutgoingMessageQueue
      Parameters:
      message - message to add
      manual_listener_notify - true for manual notification, false for automatic
    • removeMessagesOfType

      public void removeMessagesOfType(Message[] message_types, boolean manual_listener_notify)
      Description copied from interface: OutgoingMessageQueue
      Remove all messages of the given types from the queue. NOTE: Allows for manual listener notification at some later time, using doListenerNotifications(), instead of notifying immediately from within this method. This is useful if you want to invoke listeners outside of some greater synchronised block to avoid deadlock.
      Specified by:
      removeMessagesOfType in interface OutgoingMessageQueue
      Parameters:
      message_types - type to remove
      manual_listener_notify - true for manual notification, false for automatic
    • removeMessage

      public boolean removeMessage(Message message, boolean manual_listener_notify)
      Description copied from interface: OutgoingMessageQueue
      Remove a particular message from the queue. NOTE: Only the original message found in the queue will be destroyed upon removal, which may not necessarily be the one passed as the method parameter, as some messages override equals() (i.e. BTRequest messages) instead of using reference equality, and could be a completely different object, and would need to be destroyed manually. If the message does not override equals, then any such method will likely *not* be found and removed, as internal queued object was a new allocation on insertion. NOTE: Allows for manual listener notification at some later time, using doListenerNotifications(), instead of notifying immediately from within this method. This is useful if you want to invoke listeners outside of some greater synchronised block to avoid deadlock.
      Specified by:
      removeMessage in interface OutgoingMessageQueue
      Parameters:
      message - to remove
      manual_listener_notify - true for manual notification, false for automatic
      Returns:
      true if the message was removed, false otherwise
    • deliverToTransport

      public int[] deliverToTransport(int max_bytes, boolean protocol_is_free, boolean manual_listener_notify) throws IOException
      Description copied from interface: OutgoingMessageQueue
      Deliver (write) message(s) data to the underlying transport. NOTE: Allows for manual listener notification at some later time, using doListenerNotifications(), instead of notifying immediately from within this method. This is useful if you want to invoke listeners outside of some greater synchronised block to avoid deadlock.
      Specified by:
      deliverToTransport in interface OutgoingMessageQueue
      Parameters:
      max_bytes - maximum number of bytes to deliver
      manual_listener_notify - true for manual notification, false for automatic
      Returns:
      number of bytes delivered as [data, protocol]
      Throws:
      IOException - on delivery error
    • doListenerNotifications

      public void doListenerNotifications()
      Description copied from interface: OutgoingMessageQueue
      Manually send any unsent listener notifications.
      Specified by:
      doListenerNotifications in interface OutgoingMessageQueue
    • setTrace

      public void setTrace(boolean on)
      Specified by:
      setTrace in interface OutgoingMessageQueue
    • getQueueTrace

      public String getQueueTrace()
      Specified by:
      getQueueTrace in interface OutgoingMessageQueue
    • registerQueueListener

      public void registerQueueListener(OutgoingMessageQueue.MessageQueueListener listener)
      Description copied from interface: OutgoingMessageQueue
      Add a listener to be notified of queue events.
      Specified by:
      registerQueueListener in interface OutgoingMessageQueue
    • cancelQueueListener

      public void cancelQueueListener(OutgoingMessageQueue.MessageQueueListener listener)
      Description copied from interface: OutgoingMessageQueue
      Cancel queue event notification listener.
      Specified by:
      cancelQueueListener in interface OutgoingMessageQueue
    • notifyOfExternallySentMessage

      public void notifyOfExternallySentMessage(Message message)
      Description copied from interface: OutgoingMessageQueue
      Notifty the queue (and its listeners) of a message sent externally on the queue's behalf.
      Specified by:
      notifyOfExternallySentMessage in interface OutgoingMessageQueue
      Parameters:
      message - sent externally