Class EventRegister
- java.lang.Object
-
- nxt.http.APIServlet.APIRequestHandler
-
- nxt.http.EventRegister
-
public class EventRegister extends APIServlet.APIRequestHandler
The EventRegister API will create an event listener and register one or more server events. The 'add' and 'remove' parameters must be omitted or must both be false in order to create a new event listener.
After calling EventRegister, the application needs to call the EventWait API to wait for one of the registered events to occur. The events will remain registered so successive calls to EventWait can be made without another call to EventRegister.
When the event listener is no longer needed, the application should call EventRegister with an empty event list and 'remove=true'. An outstanding event wait will be completed and the event listener will be canceled.
An existing event list can be modified by calling EventRegister with either 'add=true' or 'remove=true'. The current event list will be replaced if both parameters are omitted or are false.
Event registration will be canceled if the application does not issue an EventWait before the time interval specified by nxt.apiEventTimeout expires. The timer is reset each time an EventWait is processed.
An application cannot register events if the maximum number of event users specified by nxt.apiMaxEventUsers has been reached.
Request parameters:
- event - Event name. The 'event' parameter can be repeated to specify multiple events. All events will be included if the 'event' parameter is not specified.
- add - Specify 'true' to add the events to an existing event list.
- remove - Specify 'true' to remove the events from an existing event list.
Response parameters:
- registered - Set to 'true' if the events were processed.
Error Response parameters:
- errorCode - API error code
- errorDescription - API error description
Event names:
- Block.BLOCK_GENERATED
- Block.BLOCK_POPPED
- Block.BLOCK_PUSHED
- Ledger.ADD_ENTRY - Changes to all accounts will be reported.
- Ledger.ADD_ENTRY.account - Only changes to the specified account will be reported. 'account' may be the numeric identifier or the Reed-Solomon identifier of the account to monitor for updates. Specifying an account identifier of 0 is the same as not specifying an account.
- Peer.ADD_INBOUND
- Peer.ADDED_ACTIVE_PEER
- Peer.BLACKLIST
- Peer.CHANGED_ACTIVE_PEER
- Peer.DEACTIVATE
- Peer.NEW_PEER
- Peer.REMOVE
- Peer.REMOVE_INBOUND
- Peer.UNBLACKLIST
- Transaction.ADDED_CONFIRMED_TRANSACTIONS
- Transaction.ADDED_UNCONFIRMED_TRANSACTIONS
- Transaction.REJECT_PHASED_TRANSACTION
- Transaction.RELEASE_PHASED_TRANSACTION
- Transaction.REMOVE_UNCONFIRMED_TRANSACTIONS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
allowRequiredBlockParameters()
No required block parametersprotected org.json.simple.JSONStreamAware
processRequest(javax.servlet.http.HttpServletRequest req)
Process the EventRegister API requestprotected boolean
requirePost()
-
Methods inherited from class nxt.http.APIServlet.APIRequestHandler
getAPITags, getFileParameter, getParameters, isPassword, isTextArea, processRequest, requireBlockchain, requireFullClient, requirePassword, startDbTransaction
-
-
-
-
Method Detail
-
processRequest
protected org.json.simple.JSONStreamAware processRequest(javax.servlet.http.HttpServletRequest req)
Process the EventRegister API request- Specified by:
processRequest
in classAPIServlet.APIRequestHandler
- Parameters:
req
- API request- Returns:
- API response
-
requirePost
protected final boolean requirePost()
- Overrides:
requirePost
in classAPIServlet.APIRequestHandler
-
allowRequiredBlockParameters
protected boolean allowRequiredBlockParameters()
No required block parameters- Overrides:
allowRequiredBlockParameters
in classAPIServlet.APIRequestHandler
- Returns:
- FALSE to disable the required block parameters
-
-