Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Data shapeServer APIGenerated

EventBus

Defined in: server/api.d.ts:8309

Asynchronous resource event bus.

emit(eventName, …args): Promise<void>

Defined in: server/api.d.ts:8360

Invokes every shared handler and waits for all synchronous and asynchronous results.

string

Shared event name.

…unknown[]

Arguments delivered to every matching handler.

Promise<void>

Promise rejected with an AggregateError when one or more handlers fail.


emitAllClients(eventName, payload?): void

Defined in: server/api.d.ts:8398

Broadcasts a named event to every connected client’s shared Events handlers.

string

Client shared-event name.

unknown

Optional string payload sent verbatim; other values are JSON-serialized.

void


emitLocal(eventName, …args): Promise<void>

Defined in: server/api.d.ts:8384

Emits an event only within the calling resource.

string

Private local event name.

…unknown[]

Arguments delivered only to handlers owned by the calling resource.

Promise<void>

Promise rejected when one or more local handlers fail.


emitTo(resourceName, eventName, …args): Promise<void>

Defined in: server/api.d.ts:8369

Invokes matching handlers belonging only to one resource.

string

Destination running resource.

string

Shared event name.

…unknown[]

Arguments delivered to matching handlers owned by the destination.

Promise<void>

Promise rejected when one or more destination handlers fail.


listenerCount(eventName): number

Defined in: server/api.d.ts:8391

Counts persistent and one-shot shared handlers across resources.

string

Shared event name to inspect.

number

Number of matching handlers.


off<K>(eventName, handler): void

Defined in: server/api.d.ts:8345

Removes a matching handler owned by the calling resource.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

void

off(eventName, handler): void

Defined in: server/api.d.ts:8352

Removes a matching handler owned by the calling resource.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


offClient(eventName, handler): void

Defined in: server/api.d.ts:8420

Removes a matching client-originated event handler owned by the calling resource.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


on<K>(eventName, handler): Unsubscribe

Defined in: server/api.d.ts:8316

Registers a persistent handler in the shared event namespace.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.

on(eventName, handler): Unsubscribe

Defined in: server/api.d.ts:8324

Registers a persistent handler in the shared event namespace.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.


once<K>(eventName, handler): void

Defined in: server/api.d.ts:8331

Registers a handler that is removed before its first invocation.

K extends keyof EventMap

K

Case-sensitive event name.

(…args) => unknown

Resource-owned callback invoked with the emitted arguments.

void

once(eventName, handler): void

Defined in: server/api.d.ts:8338

Registers a handler that is removed before its first invocation.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


onceClient(eventName, handler): void

Defined in: server/api.d.ts:8413

Registers a one-shot server handler for a client-originated event.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void


onClient(eventName, handler): Unsubscribe

Defined in: server/api.d.ts:8406

Registers a persistent server handler for events originating from clients; this namespace is isolated from native events.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

Unsubscribe

Function that removes this exact subscription.


onLocal(eventName, handler): void

Defined in: server/api.d.ts:8376

Registers a handler in the calling resource’s private local-event namespace.

string

Case-sensitive event name.

EventHandler

Resource-owned callback invoked with the emitted arguments.

void