Package nxt.http

Class EventWait

  • public class EventWait
    extends APIServlet.APIRequestHandler

    The EventWait API will wait for one of the server events registered by EventRegister. EventWait will return immediately if one or more events have occurred since the last time EventWait was called. All pending events will be returned in a single response. The events remain registered so successive calls to EventWait can be made without another call to EventRegister.

    Only one EventWait can be outstanding for the same network address. If a second EventWait is issued, the current EventWait will be replaced by the new EventWait.

    Request parameters:

    • timeout - Number of seconds to wait for an event. The EventWait will complete normally if no event is received within the timeout interval. nxt.apiEventTimeout will be used if no timeout value is specified or if the requested timeout is greater than nxt.apiEventTimeout.

    Response parameters:

    • events - An array of event objects

    Error Response parameters:

    • errorCode - API error code
    • errorDescription - API error description

    Event object:

    • name - The event name
    • ids - An array of event object identifiers

    Event names:

    • Block.BLOCK_POPPED
    • Block.BLOCK_PUSHED
    • Ledger.ADD_ENTRY.account - The account suffix will be Reed-Solomon identifier of the account associated with the ledger entry.
    • Peer.ADD_INBOUND
    • Peer.BLACKLIST
    • Peer.NEW_PEER
    • Peer.REMOVE

    Event object identifiers:

    • Block string identifier for a Block event
    • Peer network address for a Peer event
    • Transaction string identifier for a Transaction event
    • Method Detail

      • processRequest

        protected org.json.simple.JSONStreamAware processRequest​(javax.servlet.http.HttpServletRequest req)
        Process the EventWait API request The response will be returned immediately if there are any pending events. Otherwise, an asynchronous context will be created and the response will be returned after the wait has completed. By using an asynchronous context, we avoid tying up the Jetty servlet thread while waiting for an event.
        Specified by:
        processRequest in class APIServlet.APIRequestHandler
        req - API request
        API response or null