nxt.http

## Class EventWait

- java.lang.Object
- - nxt.http.APIServlet.APIRequestHandler
  - - nxt.http.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.

  Request parameters:

  - token - Event registration token returned by the EventRegister API.
  - 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_GENERATED
  - Block.BLOCK_POPPED
  - Block.BLOCK_PUSHED
  - Ledger.ADD_ENTRY.account - Monitor changes to the specified account. 'account' may be the numeric identifier or the Reed-Solomon identifier of the account to monitor for updates. All accounts will be monitored if no account is specified. Specifying an account identifier of 0 is the same as not specifying an account.
  - Peer.ADD_ACTIVE_PEER
  - Peer.ADD_PEER
  - Peer.BLACKLIST
  - Peer.CHANGE_ACTIVE_PEER
  - Peer.CHANGE_ANNOUNCED_ADDRESS
  - Peer.CHANGE_SERVICES
  - Peer.REMOVE_PEER
  - Peer.UNBLACKLIST
  - Transaction.ADDED_CONFIRMED_TRANSACTIONS.account (omit account to monitor all accounts)
  - Transaction.ADDED_UNCONFIRMED_TRANSACTIONS.account (omit account to monitor all accounts)
  - Transaction.REJECT_PHASED_TRANSACTION.account (omit account to monitor all accounts)
  - Transaction.RELEASE_PHASED_TRANSACTION.account (omit account to monitor all accounts)
  - Transaction.REMOVED_UNCONFIRMED_TRANSACTIONS.account (omit account to monitor all accounts)

  Event object identifiers:

  - Block string identifier for a Block event
  - Peer network address for a Peer event
  - Transaction chain and full hash for a Transaction event as a string in the format 'chain:hash'

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `allowRequiredBlockParameters()`
    `protected boolean` | `isChainSpecific()`
    `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.
    `protected boolean` | `requirePost()`

    - ### Methods inherited from class nxt.http.APIServlet.APIRequestHandler

      `getAPITags, getFileParameter, getParameters, isIgnisOnly, isPassword, isTextArea, processRequest, requireBlockchain, requireFullClient, requirePassword, startDbTransaction`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### processRequest

          protected org.json.simple.JSONStreamAware processRequest(javax.servlet.http.HttpServletRequest req)
                                                            throws ParameterException

      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`
      Parameters:
        `req` - API request
      Returns:
        API response or null
      Throws:
        `ParameterException` - Invalid parameter specified

    - #### requirePost

          protected final boolean requirePost()

      Overrides:
        `requirePost` in class `APIServlet.APIRequestHandler`

    - #### allowRequiredBlockParameters

          protected boolean allowRequiredBlockParameters()

      Overrides:
        `allowRequiredBlockParameters` in class `APIServlet.APIRequestHandler`

    - #### isChainSpecific

          protected boolean isChainSpecific()

      Overrides:
        `isChainSpecific` in class `APIServlet.APIRequestHandler`