Class: WsEndpoint
WebSocket connection to Chronik.
Constructors
constructor
• new WsEndpoint(proxyInterface
, config
): WsEndpoint
Parameters
Name | Type |
---|---|
proxyInterface | FailoverProxy |
config | WsConfig |
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
: SubscribeMsg
) => void
Fired when a message is sent from the WebSocket.
Type declaration
▸ (msg
): void
Parameters
Name | Type |
---|---|
msg | SubscribeMsg |
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: { scriptPayload
: string
; scriptType
: ScriptType
}[]
Defined in
ws
• ws: undefined
| WebSocket
Defined in
Methods
close
▸ close(): void
Close the WebSocket connection and prevent future any reconnection attempts.
Returns
void
Defined in
handleMsg
▸ handleMsg(wsMsg
): Promise
<void
>
Parameters
Name | Type |
---|---|
wsMsg | MessageEvent |
Returns
Promise
<void
>
Defined in
subUnsub
▸ subUnsub(isSubscribe
, scriptType
, scriptPayload
): void
Parameters
Name | Type |
---|---|
isSubscribe | boolean |
scriptType | ScriptType |
scriptPayload | string |
Returns
void
Defined in
subscribe
▸ subscribe(scriptType
, scriptPayload
): void
Subscribe to the given script type and payload.
For "p2pkh", scriptPayload
is the 20 byte public key hash.
Parameters
Name | Type |
---|---|
scriptType | ScriptType |
scriptPayload | string |
Returns
void
Defined in
unsubscribe
▸ unsubscribe(scriptType
, scriptPayload
): void
Unsubscribe from the given script type and payload.
Parameters
Name | Type |
---|---|
scriptType | ScriptType |
scriptPayload | string |
Returns
void
Defined in
waitForOpen
▸ waitForOpen(): Promise
<void
>
Wait for the WebSocket to be connected.
Returns
Promise
<void
>