Skip to content

WebSocketSubscription

A subscription created within a WebSocketConnection.

Extends

Type parameters

Type parameterValue
T extends SubscriptionTypesSubscriptionTypes

Constructors

new WebSocketSubscription()

1
new WebSocketSubscription<T>(
2
connection: WebSocketConnection,
3
options: SubscriptionOptions<T>,
4
data: PostEventSubSubscription): WebSocketSubscription<T>

Builds up a new WebSocketSubscription.

Parameters

ParameterTypeDescription
connectionWebSocketConnectionThe connection used for this subscription.
optionsSubscriptionOptions<T>The options for the subscription.
dataPostEventSubSubscriptionThe data for the subscription.

Returns

WebSocketSubscription<T>

Overrides

Subscription.constructor

Source

twitchfy/packages/eventsub/src/ws/structures/WebSocketSubscription.ts:32

Properties

PropertyModifierTypeDescriptionInherited from
callbacksreadonlyWebSocketSubscriptionCallbackManager<T>The callback manager for this subscription.-
connectionreadonlyWebSocketConnectionThe connection used for this subscription.-
costreadonlynumberThe cost of the subscription. If the subscription doesn’t needs an authorization this could be 1 (or 0 if the target user has authorized within your application) if not it will be 0. Maximum accumulated cost for webhooks subscriptions is 10000 while for websocket subscriptions is 3.Subscription.cost
createdAtreadonlyDateThe date when the subscription was created.Subscription.createdAt
idreadonlystringThe ID of the subscription.Subscription.id
noncepublicstringThe nonce of the subscription. An unique identifier which you can set to separate same type subscriptions.Subscription.nonce
optionsreadonlySubscriptionTypeOptions[T]The options used to create the subscription.Subscription.options
statuspublicstringThe status of the subscription. Normally is ‘enabled’.Subscription.status
typereadonlyTThe type of the subscription.Subscription.type
versionreadonlystringThe version of the subscription. This version is the latest version of the subscription type.Subscription.version

Methods

checkSubscriptionType()

1
checkSubscriptionType<U>(type: U): this is WebSocketSubscription<U>

Checks if the subscription is of a specific type.

Type parameters

Type parameter
U extends SubscriptionTypes

Parameters

ParameterTypeDescription
typeUThe type to check.

Returns

this is WebSocketSubscription<U>

Whether the subscription is of the type.

Source

twitchfy/packages/eventsub/src/ws/structures/WebSocketSubscription.ts:62


delete()

1
delete(): Promise<void>

Deletes the subscription.

Returns

Promise<void>

Source

twitchfy/packages/eventsub/src/ws/structures/WebSocketSubscription.ts:69


onMessage()

1
onMessage(callback: WebSocketSubscriptionCallback<T>): void

Adds a new callback to the subscription. This callback will be executed when a message within this subscription is received.

Parameters

ParameterTypeDescription
callbackWebSocketSubscriptionCallback<T>The callback to add.

Returns

void

Source

twitchfy/packages/eventsub/src/ws/structures/WebSocketSubscription.ts:51