Class: WsEndpoint_InNode
WebSocket connection to Chronik.
Constructors
constructor
• new WsEndpoint_InNode(proxyInterface
, config
): WsEndpoint_InNode
Parameters
Name | Type |
---|---|
proxyInterface | FailoverProxy |
config | WsConfig_InNode |
Returns
Defined in
Properties
autoReconnect
• autoReconnect: boolean
Whether to automatically reconnect on disconnect, default true.
Defined in
connected
• connected: undefined
| Promise
<Event
>
Defined in
manuallyClosed
• manuallyClosed: boolean
Defined in
onConnect
• Optional
onConnect: (e
: Event
) => void
Fired when a connection has been (re)established.
Type declaration
▸ (e
): void
Parameters
Name | Type |
---|---|
e | Event |
Returns
void
Defined in
onEnd
• Optional
onEnd: (e
: Event
) => void
Fired after a connection has been manually closed, or if autoReconnect
is false, if the WebSocket disconnects for any reason.
Type declaration
▸ (e
): void
Parameters
Name | Type |
---|---|
e | Event |
Returns
void
Defined in
onError
• Optional
onError: (e
: ErrorEvent
) => void
Fired when an error with the WebSocket occurs.
Type declaration
▸ (e
): void
Parameters
Name | Type |
---|---|
e | ErrorEvent |
Returns
void
Defined in
onMessage
• Optional
onMessage: (msg
: WsMsgClient
) => void
Fired when a message is sent from the WebSocket.
Type declaration
▸ (msg
): void
Parameters
Name | Type |
---|---|
msg | WsMsgClient |
Returns
void
Defined in
onReconnect
• Optional
onReconnect: (e
: Event
) => void
Fired after a connection has been unexpectedly closed, and before a
reconnection attempt is made. Only fired if autoReconnect
is true.
Type declaration
▸ (e
): void
Parameters
Name | Type |
---|---|
e | Event |
Returns
void
Defined in
subs
• subs: WsSubscriptions
Defined in
ws
• ws: undefined
| WebSocket
Defined in
Methods
close
▸ close(): void
Close the WebSocket connection and prevent any future reconnection attempts.
Returns
void
Defined in
handleMsg
▸ handleMsg(wsMsg
): Promise
<void
>
Parameters
Name | Type |
---|---|
wsMsg | MessageEvent |
Returns
Promise
<void
>
Defined in
subscribeToAddress
▸ subscribeToAddress(address
): void
Subscribe to an address Method can be used for p2pkh or p2sh addresses
Parameters
Name | Type |
---|---|
address | string |
Returns
void
Defined in
subscribeToBlocks
▸ subscribeToBlocks(): void
Subscribe to block messages
Returns
void
Defined in
subscribeToScript
▸ subscribeToScript(type
, payload
): void
Subscribe to the given script type and payload.
For "p2pkh", scriptPayload
is the 20 byte public key hash.
Parameters
Name | Type |
---|---|
type | ScriptType_InNode |
payload | string |
Returns
void
Defined in
unsubscribeFromAddress
▸ unsubscribeFromAddress(address
): void
Unsubscribe from the given address
Parameters
Name | Type |
---|---|
address | string |
Returns
void
Defined in
unsubscribeFromBlocks
▸ unsubscribeFromBlocks(): void
Unsubscribe from block messages
Returns
void
Defined in
unsubscribeFromScript
▸ unsubscribeFromScript(type
, payload
): void
Unsubscribe from the given script type and payload.
Parameters
Name | Type |
---|---|
type | ScriptType_InNode |
payload | string |
Returns
void
Defined in
waitForOpen
▸ waitForOpen(): Promise
<void
>
Wait for the WebSocket to be connected.
Returns
Promise
<void
>