Skip to content
Developer Preview

Connection

One MSP connection over newline-delimited JSON.

The connection sends your requests and commands, correlates their responses, enforces the frame-size limit, and hands inbound notifications and server requests to the handlers you register. It is transport-agnostic: pair it with any DuplexTransport. Most applications never build one directly — MuseClient.spawn or spawnMspConnection does it for you; reach for a bare Connection when you need the raw notification feed or your own transport.

Property Type Stability Presence Description
closed Promise<void> required
Method Signature Stability Description
constructor new Connection(transport: DuplexTransport, options?: ConnectionOptions)
close close(): Promise<void>
command command(method: string, params: Record<string, unknown>, options?: CommandOptions): Promise<Record<string, unknown>>
flush flush(): Promise<void>
mintCommandId mintCommandId(): string Take one id from THIS connection’s single commandId minter.
notify notify(method: string, params?: Record<string, unknown>): void
onNotification onNotification(handler: NotificationHandler): void
onProtocolError onProtocolError(handler: ProtocolErrorHandler): void
onServerRequest onServerRequest(handler: ServerRequestHandler): void
request request(method: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>
Source

clients/sdk-ts/src/connection/connection.ts:221

{
"kind": "Class",
"canonicalPath": "Connection"
}