Interface Network.Handler

Enclosing interface:
Network

public static interface Network.Handler
Callback interface used by Network implementations.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handle(String peer, ByteBuffer msg)
    Handle an incoming message from a remote peer.
    void
    Handle notification that a remote peer's output queue has transitioned from a non empty state to an empty state.
  • Method Details

    • handle

      void handle(String peer, ByteBuffer msg)
      Handle an incoming message from a remote peer.

      The msg buffer is read-only; its contents are not guaranteed to be valid after this method returns.

      Note that due to inherent race conditions with multiple threads, it is possible for this method to be invoked (at most once) after Network.stop() has returned.

      Parameters:
      peer - message source
      msg - message received
    • outputQueueEmpty

      void outputQueueEmpty(String peer)
      Handle notification that a remote peer's output queue has transitioned from a non empty state to an empty state.

      This notification can be used for flow-control, i.e., to prevent the local output queue for peer from growing without bound if there is network congestion, or the peer is slow to read messages, etc.

      Note that due to inherent race conditions with multiple threads, it is possible for this method to be invoked (at most once) after Network.stop() has returned.

      Parameters:
      peer - remote peer