WebSocketShardConnector
A WebSocket Shard Connector for connecting to Twitch WebSocket EventSub service.
Extends
client
Constructors
new WebSocketShardConnector()
Builds up a WebSocketShardConnector.
Parameters
Parameter | Type | Description |
---|---|---|
connection | WebSocketShard | The WebSocket Shard to connect to. |
Returns
Overrides
client.constructor
Source
twitchfy/packages/eventsub/src/structures/WebSocketShardConnector.ts:41
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
connection | readonly | WebSocketShard | The WebSocket Shard to connect to. | - |
connectionURL | public | string | The connection URL of the WebSocket server used. | - |
sessionId | readonly | string | The session id of the shard. | - |
wsConnection | public | connection | The WebSocket connection used. | - |
captureRejectionSymbol | readonly | typeof captureRejectionSymbol | Value: See how to write a custom Since v13.4.0, v12.16.0 | client.captureRejectionSymbol |
captureRejections | static | boolean | Value: boolean Change the default Since v13.4.0, v12.16.0 | client.captureRejections |
defaultMaxListeners | static | number | By default, a maximum of Take caution when setting the This is not a hard limit. The import { EventEmitter } from ‘node:events
’; The The emitted warning can be inspected with Since v0.11.2 | client.defaultMaxListeners |
errorMonitor | readonly | typeof errorMonitor | This symbol shall be used to install a listener for only monitoring Installing a listener using this symbol does not change the behavior once an Since v13.6.0, v12.17.0 | client.errorMonitor |
Methods
[captureRejectionSymbol]
()?
Parameters
Parameter | Type |
---|---|
error | Error |
event | string |
…args | any [] |
Returns
void
Inherited from
client.[captureRejectionSymbol]
Source
twitchfy/node_modules/@types/node/events.d.ts:112
abort()
Will cancel an in-progress connection request before either the connect
event or the connectFailed
event has been emitted.
If the connect
or connectFailed
event has already been emitted, calling abort()
will do nothing.
Returns
void
Inherited from
client.abort
Source
twitchfy/node_modules/@types/websocket/index.d.ts:642
addListener()
addListener(event, cb)
Parameters
Parameter | Type |
---|---|
event | "connect" |
cb | (connection : connection ) => void |
Returns
this
Inherited from
client.addListener
Source
twitchfy/node_modules/@types/websocket/index.d.ts:648
addListener(event, cb)
Parameters
Parameter | Type |
---|---|
event | "connectFailed" |
cb | (err : Error ) => void |
Returns
this
Inherited from
client.addListener
Source
twitchfy/node_modules/@types/websocket/index.d.ts:649
addListener(event, cb)
Parameters
Parameter | Type |
---|---|
event | "httpResponse" |
cb | (response : IncomingMessage , client : client ) => void |
Returns
this
Inherited from
client.addListener
Source
twitchfy/node_modules/@types/websocket/index.d.ts:650
connect()
Connects to the WebSocket server.
Parameters
Parameter | Type | Description |
---|---|---|
url ? | string | The URL to connect to. If not specified it will use the default Twitch connection. |
Returns
Promise
<void
>
Overrides
client.connect
Source
twitchfy/packages/eventsub/src/structures/WebSocketShardConnector.ts:58
emit()
Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
Parameters
Parameter | Type |
---|---|
eventName | string | symbol |
…args | any [] |
Returns
boolean
Inherited from
client.emit
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:807
eventNames()
Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
Returns
(string
| symbol
)[]
Inherited from
client.eventNames
Since
v6.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:870
getMaxListeners()
Returns the current max listener value for the EventEmitter
which is either
set by emitter.setMaxListeners(n)
or defaults to defaultMaxListeners.
Returns
number
Inherited from
client.getMaxListeners
Since
v1.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:722
listenerCount()
Returns the number of listeners listening for the event named eventName
.
If listener
is provided, it will return how many times the listener is found
in the list of the listeners of the event.
Parameters
Parameter | Type | Description |
---|---|---|
eventName | string | symbol | The name of the event being listened for |
listener ? | Function | The event handler function |
Returns
number
Inherited from
client.listenerCount
Since
v3.2.0
Source
twitchfy/node_modules/@types/node/events.d.ts:816
listeners()
Returns a copy of the array of listeners for the event named eventName
.
Parameters
Parameter | Type |
---|---|
eventName | string | symbol |
Returns
Function
[]
Inherited from
client.listeners
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:735
off()
Alias for emitter.removeListener()
.
Parameters
Parameter | Type |
---|---|
eventName | string | symbol |
listener | (…args : any []) => void |
Returns
this
Inherited from
client.off
Since
v10.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:695
on()
on(event, cb)
Parameters
Parameter | Type |
---|---|
event | "connect" |
cb | (connection : connection ) => void |
Returns
this
Inherited from
client.on
Source
twitchfy/node_modules/@types/websocket/index.d.ts:645
on(event, cb)
Parameters
Parameter | Type |
---|---|
event | "connectFailed" |
cb | (err : Error ) => void |
Returns
this
Inherited from
client.on
Source
twitchfy/node_modules/@types/websocket/index.d.ts:646
on(event, cb)
Parameters
Parameter | Type |
---|---|
event | "httpResponse" |
cb | (response : IncomingMessage , client : client ) => void |
Returns
this
Inherited from
client.on
Source
twitchfy/node_modules/@types/websocket/index.d.ts:647
once()
Adds a one-timelistener
function for the event named eventName
. The
next time eventName
is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
By default, event listeners are invoked in the order they are added. Theemitter.prependOnceListener()
method can be used as an alternative to add the
event listener to the beginning of the listeners array.
Parameters
Parameter | Type | Description |
---|---|---|
eventName | string | symbol | The name of the event. |
listener | (…args : any []) => void | The callback function |
Returns
this
Inherited from
client.once
Since
v0.3.0
Source
twitchfy/node_modules/@types/node/events.d.ts:607
prependListener()
Adds the listener
function to the beginning of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
Returns a reference to the EventEmitter
, so that calls can be chained.
Parameters
Parameter | Type | Description |
---|---|---|
eventName | string | symbol | The name of the event. |
listener | (…args : any []) => void | The callback function |
Returns
this
Inherited from
client.prependListener
Since
v6.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:834
prependOnceListener()
Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this
listener is removed, and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
Parameters
Parameter | Type | Description |
---|---|---|
eventName | string | symbol | The name of the event. |
listener | (…args : any []) => void | The callback function |
Returns
this
Inherited from
client.prependOnceListener
Since
v6.0.0
Source
twitchfy/node_modules/@types/node/events.d.ts:850
rawListeners()
Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
Parameters
Parameter | Type |
---|---|
eventName | string | symbol |
Returns
Function
[]
Inherited from
client.rawListeners
Since
v9.4.0
Source
twitchfy/node_modules/@types/node/events.d.ts:766
removeAllListeners()
Removes all listeners, or those of the specified eventName
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter
, so that calls can be chained.
Parameters
Parameter | Type |
---|---|
event ? | string | symbol |
Returns
this
Inherited from
client.removeAllListeners
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:706
removeListener()
Removes the specified listener
from the listener array for the event namedeventName
.
removeListener()
will remove, at most, one instance of a listener from the
listener array. If any single listener has been added multiple times to the
listener array for the specified eventName
, then removeListener()
must be
called multiple times to remove each instance.
Once an event is emitted, all listeners attached to it at the
time of emitting are called in order. This implies that anyremoveListener()
or removeAllListeners()
calls after emitting and before the last listener finishes execution
will not remove them fromemit()
in progress. Subsequent events behave as expected.
Because listeners are managed using an internal array, calling this will
change the position indices of any listener registered after the listener
being removed. This will not impact the order in which listeners are called,
but it means that any copies of the listener array as returned by
the emitter.listeners()
method will need to be recreated.
When a single function has been added as a handler multiple times for a single
event (as in the example below), removeListener()
will remove the most
recently added instance. In the example the once('ping')
listener is removed:
Returns a reference to the EventEmitter
, so that calls can be chained.
Parameters
Parameter | Type |
---|---|
eventName | string | symbol |
listener | (…args : any []) => void |
Returns
this
Inherited from
client.removeListener
Since
v0.1.26
Source
twitchfy/node_modules/@types/node/events.d.ts:690
setMaxListeners()
By default EventEmitter
s will print a warning if more than 10
listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. The emitter.setMaxListeners()
method allows the limit to be
modified for this specific EventEmitter
instance. The value can be set toInfinity
(or 0
) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter
, so that calls can be chained.
Parameters
Parameter | Type |
---|---|
n | number |
Returns
this
Inherited from
client.setMaxListeners
Since
v0.3.5
Source
twitchfy/node_modules/@types/node/events.d.ts:716
addAbortListener()
Experimental
Listens once to the abort
event on the provided signal
.
Listening to the abort
event on abort signals is unsafe and may
lead to resource leaks since another third party with the signal can
call e.stopImmediatePropagation()
. Unfortunately Node.js cannot change
this since it would violate the web standard. Additionally, the original
API makes it easy to forget to remove listeners.
This API allows safely using AbortSignal
s in Node.js APIs by solving these
two issues by listening to the event such that stopImmediatePropagation
does
not prevent the listener from running.
Returns a disposable so that it may be unsubscribed from more easily.
Parameters
Parameter | Type |
---|---|
signal | AbortSignal |
resource | (event : Event ) => void |
Returns
Disposable
Disposable that removes the abort
listener.
Inherited from
client.addAbortListener
Since
v20.5.0
Source
twitchfy/node_modules/@types/node/events.d.ts:387
getEventListeners()
Returns a copy of the array of listeners for the event named eventName
.
For EventEmitter
s this behaves exactly the same as calling .listeners
on
the emitter.
For EventTarget
s this is the only way to get the event listeners for the
event target. This is useful for debugging and diagnostic purposes.
Parameters
Parameter | Type |
---|---|
emitter | EventEmitter | _DOMEventTarget |
name | string | symbol |
Returns
Function
[]
Inherited from
client.getEventListeners
Since
v15.2.0, v14.17.0
Source
twitchfy/node_modules/@types/node/events.d.ts:308
getMaxListeners()
Returns the currently set max amount of listeners.
For EventEmitter
s this behaves exactly the same as calling .getMaxListeners
on
the emitter.
For EventTarget
s this is the only way to get the max event listeners for the
event target. If the number of event handlers on a single EventTarget exceeds
the max set, the EventTarget will print a warning.
Parameters
Parameter | Type |
---|---|
emitter | EventEmitter | _DOMEventTarget |
Returns
number
Inherited from
client.getMaxListeners
Since
v19.9.0
Source
twitchfy/node_modules/@types/node/events.d.ts:337
listenerCount()
A class method that returns the number of listeners for the given eventName
registered on the given emitter
.
Parameters
Parameter | Type | Description |
---|---|---|
emitter | EventEmitter | The emitter to query |
eventName | string | symbol | The event name |
Returns
number
Inherited from
client.listenerCount
Since
v0.9.12
Source
twitchfy/node_modules/@types/node/events.d.ts:280
on()
Returns an AsyncIterator
that iterates eventName
events. It will throw
if the EventEmitter
emits 'error'
. It removes all listeners when
exiting the loop. The value
returned by each iteration is an array
composed of the emitted event arguments.
An AbortSignal
can be used to cancel waiting on events:
Parameters
Parameter | Type | Description |
---|---|---|
emitter | EventEmitter | - |
eventName | string | The name of the event being listened for |
options ? | StaticEventEmitterOptions | - |
Returns
AsyncIterableIterator
<any
>
that iterates eventName
events emitted by the emitter
Inherited from
client.on
Since
v13.6.0, v12.16.0
Source
twitchfy/node_modules/@types/node/events.d.ts:258
once()
once(emitter, eventName, options)
Creates a Promise
that is fulfilled when the EventEmitter
emits the given
event or that is rejected if the EventEmitter
emits 'error'
while waiting.
The Promise
will resolve with an array of all the arguments emitted to the
given event.
This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error'
event
semantics and does not listen to the 'error'
event.
The special handling of the 'error'
event is only used when events.once()
is used to wait for another event. If events.once()
is used to wait for the
‘error'
event itself, then it is treated as any other kind of event without
special handling:
An AbortSignal
can be used to cancel waiting for the event:
Parameters
Parameter | Type |
---|---|
emitter | _NodeEventTarget |
eventName | string | symbol |
options ? | StaticEventEmitterOptions |
Returns
Promise
<any
[]>
Inherited from
client.once
Since
v11.13.0, v10.16.0
Source
twitchfy/node_modules/@types/node/events.d.ts:193
once(emitter, eventName, options)
Parameters
Parameter | Type |
---|---|
emitter | _DOMEventTarget |
eventName | string |
options ? | StaticEventEmitterOptions |
Returns
Promise
<any
[]>
Inherited from
client.once
Source
twitchfy/node_modules/@types/node/events.d.ts:198
setMaxListeners()
Parameters
Parameter | Type | Description |
---|---|---|
n ? | number | A non-negative number. The maximum number of listeners per EventTarget event. |
…eventTargets ? | (EventEmitter | _DOMEventTarget )[] | - |
Returns
void
Inherited from
client.setMaxListeners
Since
v15.4.0
Source
twitchfy/node_modules/@types/node/events.d.ts:352