Skip to content

Transport

Category: Jsonrpc

Source: transport.dart

Transport for line-delimited JSON-RPC over stream pairs (stdio, websocket bytes, in-memory pipes).

The transport is deliberately abstract — it accepts a Stream<List<int>> for input and an IOSink-shaped object for output. That lets the server be tested with in-memory streams and run for real on stdin/stdout.

Classes

abstract JsonRpcTransport

A bidirectional JSON-RPC transport. Each incoming element is one decoded message; send enqueues one message for the peer.

Properties

PropertyTypeDescription
incomingStream<JsonRpcMessage> get
incomingStream<JsonRpcMessage> get

Methods

void send(JsonRpcMessage message)

Send a message to the peer. May be called concurrently with [incoming]; implementations serialize as needed.

Future<void> close()

Closes the outbound side. The transport is expected to drain pending writes before closing.

LineDelimitedTransport

Line-delimited JSON-RPC transport. Each newline-terminated chunk on the inbound stream is one JSON-RPC message; each outbound message is written as one line followed by \n.

This is the default framing for ACP and MCP over stdio.

Constructor

dart
LineDelimitedTransport({required this._input, required this.output})

Properties

PropertyTypeDescription
outputSink<List<int>>
incomingStream<JsonRpcMessage> get

Methods

void send(JsonRpcMessage message)
Future<void> close()

Released under the MIT License.