Package com.biglybt.core.networkmanager
Interface OutgoingMessageQueue
- All Known Implementing Classes:
OutgoingMessageQueueImpl
,PeerForeignNetworkConnection.omq
public interface OutgoingMessageQueue
Priority-based outbound peer message queue.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Receive notification of queue events. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage
(Message message, boolean manual_listener_notify) Add a message to the message queue.void
Cancel queue event notification listener.int[]
deliverToTransport
(int max_bytes, boolean protocol_is_free, boolean manual_listener_notify) Deliver (write) message(s) data to the underlying transport.void
destroy()
Destroy this queue; i.e.void
Manually send any unsent listener notifications.void
flush()
Force all pending messages to be deliveredint[]
int
int
boolean
int
int
Get the total number of bytes ready to be transported.boolean
Whether or not an urgent message (one that needs an immediate send, i.e.boolean
boolean
void
notifyOfExternallySentMessage
(Message message) Notifty the queue (and its listeners) of a message sent externally on the queue's behalf.void
Add a listener to be notified of queue events.boolean
removeMessage
(Message message, boolean manual_listener_notify) Remove a particular message from the queue.void
removeMessagesOfType
(Message[] message_types, boolean manual_listener_notify) Remove all messages of the given types from the queue.void
setEncoder
(MessageStreamEncoder stream_encoder) Set the message stream encoder that will be used to encode outgoing messages.void
setPriorityBoost
(boolean boost) void
setTrace
(boolean on) void
setTransport
(Transport _transport)
-
Method Details
-
setTransport
-
getMssSize
int getMssSize() -
setEncoder
Set the message stream encoder that will be used to encode outgoing messages.- Parameters:
stream_encoder
- to use
-
getEncoder
MessageStreamEncoder getEncoder() -
getCurrentMessageProgress
int[] getCurrentMessageProgress()- Returns:
- [ total, done] or null
-
destroy
void destroy()Destroy this queue; i.e. perform cleanup actions. -
isDestroyed
boolean isDestroyed() -
getTotalSize
int getTotalSize()Get the total number of bytes ready to be transported.- Returns:
- total bytes remaining
-
getDataQueuedBytes
int getDataQueuedBytes() -
getProtocolQueuedBytes
int getProtocolQueuedBytes() -
isBlocked
boolean isBlocked() -
getPriorityBoost
boolean getPriorityBoost() -
setPriorityBoost
void setPriorityBoost(boolean boost) -
hasUrgentMessage
boolean hasUrgentMessage()Whether or not an urgent message (one that needs an immediate send, i.e. a no-delay message) is queued.- Returns:
- true if there's a message tagged for immediate write
-
peekFirstMessage
Message peekFirstMessage() -
addMessage
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.- Parameters:
message
- message to addmanual_listener_notify
- true for manual notification, false for automatic
-
removeMessagesOfType
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.- Parameters:
message_types
- type to removemanual_listener_notify
- true for manual notification, false for automatic
-
removeMessage
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.- Parameters:
message
- to removemanual_listener_notify
- true for manual notification, false for automatic- Returns:
- true if the message was removed, false otherwise
-
deliverToTransport
int[] deliverToTransport(int max_bytes, boolean protocol_is_free, boolean manual_listener_notify) throws IOException 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.- Parameters:
max_bytes
- maximum number of bytes to delivermanual_listener_notify
- true for manual notification, false for automatic- Returns:
- number of bytes delivered as [data, protocol]
- Throws:
IOException
- on delivery error
-
doListenerNotifications
void doListenerNotifications()Manually send any unsent listener notifications. -
flush
void flush()Force all pending messages to be delivered -
setTrace
void setTrace(boolean on) -
getQueueTrace
String getQueueTrace() -
registerQueueListener
Add a listener to be notified of queue events.- Parameters:
listener
-
-
cancelQueueListener
Cancel queue event notification listener.- Parameters:
listener
-
-
notifyOfExternallySentMessage
Notifty the queue (and its listeners) of a message sent externally on the queue's behalf.- Parameters:
message
- sent externally
-