Skip to content

lspeasy / core/src / SharedWorkerTransport

Class: SharedWorkerTransport

Defined in: packages/core/src/transport/shared-worker.ts:20

JSON-RPC transport for Shared Worker environments with per-client envelope routing.

Implements

Constructors

Constructor

ts
new SharedWorkerTransport(options): SharedWorkerTransport;

Defined in: packages/core/src/transport/shared-worker.ts:73

Parameters

ParameterType
optionsSharedWorkerTransportOptions

Returns

SharedWorkerTransport

Methods

close()

ts
close(): Promise<void>;

Defined in: packages/core/src/transport/shared-worker.ts:128

Close the transport connection and release resources.

Returns

Promise<void>

Implementation of

Transport.close


isConnected()

ts
isConnected(): boolean;

Defined in: packages/core/src/transport/shared-worker.ts:148

Returns true if the transport is currently connected and able to send messages.

Returns

boolean

Implementation of

Transport.isConnected


onClose()

ts
onClose(handler): Disposable;

Defined in: packages/core/src/transport/shared-worker.ts:119

Subscribe to connection close.

Parameters

ParameterTypeDescription
handler() => voidCallback invoked when the transport is closed.

Returns

Disposable

A Disposable that unsubscribes the handler when disposed.

Implementation of

Transport.onClose


onError()

ts
onError(handler): Disposable;

Defined in: packages/core/src/transport/shared-worker.ts:110

Subscribe to transport errors.

Parameters

ParameterTypeDescription
handler(error) => voidCallback invoked when a transport-level error occurs.

Returns

Disposable

A Disposable that unsubscribes the handler when disposed.

Implementation of

Transport.onError


onMessage()

ts
onMessage(handler): Disposable;

Defined in: packages/core/src/transport/shared-worker.ts:101

Subscribe to incoming messages.

Parameters

ParameterTypeDescription
handler(message) => voidCallback invoked for each received message.

Returns

Disposable

A Disposable that unsubscribes the handler when disposed.

Implementation of

Transport.onMessage


send()

ts
send(message): Promise<void>;

Defined in: packages/core/src/transport/shared-worker.ts:88

Send a message to the remote peer.

Parameters

ParameterTypeDescription
messageMessageThe JSON-RPC message to send.

Returns

Promise<void>

Throws

If the transport is not connected or an I/O error occurs.

Implementation of

Transport.send

Released under the MIT License.