@nymproject/mix-websocket • Docs
@nymproject/mix-websocket / MixWebSocket
Class: MixWebSocket
WebSocket-like channel over the Nym mixnet. The tunnel must already be
set up (setupMixTunnel()) before constructing one.
Differences from the browser WebSocket:
- Constructor resolves asynchronously; use
await ws.opened()if you need to block until the upgrade completes. binaryTypeis fixed toarraybuffer(no Blob support).- No
bufferedAmount; the tunnel queues writes through the worker.
Extends
EventTarget
Constructors
new MixWebSocket()
new MixWebSocket(
url,protocols?):MixWebSocket
Parameters
• url: string
• protocols?: string | string[]
Returns
Overrides
EventTarget.constructor
Source
mix-websocket/src/index.ts:44 (opens in a new tab)
Properties
url
readonlyurl:string
Source
mix-websocket/src/index.ts:38 (opens in a new tab)
protocols
readonlyprotocols:string[]
Source
mix-websocket/src/index.ts:39 (opens in a new tab)
handleIdPromise
privatehandleIdPromise:Promise<number>
Source
mix-websocket/src/index.ts:41 (opens in a new tab)
state
privatestate:MixWebSocketReadyState=CONNECTING
Source
mix-websocket/src/index.ts:42 (opens in a new tab)
Accessors
readyState
getreadyState():MixWebSocketReadyState
Returns
Source
mix-websocket/src/index.ts:76 (opens in a new tab)
Methods
opened()
opened():
Promise<void>
Block until the WebSocket transitions out of CONNECTING. Resolves when
open fires (or when the connection fails before opening).
Returns
Promise<void>
Source
mix-websocket/src/index.ts:84 (opens in a new tab)
send()
send(
data):Promise<void>
Parameters
• data: string | ArrayBuffer | Uint8Array
Returns
Promise<void>
Source
mix-websocket/src/index.ts:97 (opens in a new tab)
close()
close(
code,reason):Promise<void>
Parameters
• code: number= 1000
• reason: string= ''
Returns
Promise<void>
Source
mix-websocket/src/index.ts:106 (opens in a new tab)
handleEvent()
privatehandleEvent(type,data):void
Parameters
• type: WsEventType
• data: unknown
Returns
void