Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / WebSocketFactory

Type Alias: WebSocketFactory

WebSocketFactory = (url) => EngineWebSocket

Defined in: packages/ts-sdk/src/internal/transport.ts:75

Factory used to create WebSocket clients.

Use this in runtimes without a global browser-style WebSocket.

Example:

ts
import type { 
WebSocketFactory
} from '@my-swu/simulator-client'
const
webSocketFactory
:
WebSocketFactory
=
url
=> new
WebSocket
(
url
)
console
.
log
(
webSocketFactory
)

Parameters

url

Example:

ts
import type { 
WebSocketFactory
} from '@my-swu/simulator-client'
// The SDK calls this with the resolved match socket URL. const
webSocketFactory
:
WebSocketFactory
= (
socketUrl
) => new
WebSocket
(
socketUrl
)

string

Returns

EngineWebSocket

Example

ts
import WebSocket from 'ws'
import type { WebSocketFactory } from '@my-swu/simulator-client'

const nodeWebSocketFactory: WebSocketFactory = url => new WebSocket(url)
console.log(typeof nodeWebSocketFactory)

See

https://simulator-sdk.my-swu.com/guide/runtime-adapters

Released under the MIT License.