Skip to content

Commit b428353

Browse files
Dr-Emannkentonv
andauthored
docs: add info about transport/framing to protocol.md (#137)
* docs: add info about transport/framing to protocol.md * Apply suggestions from code review --------- Co-authored-by: Kenton Varda <kenton@cloudflare.com>
1 parent c2bb17b commit b428353

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

protocol.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ The protocol does not have a "client" or a "server"; it is fully bidirectional.
2424

2525
With that said, for documentation purposes, we often use the words "client" and "server" when describing specific interactions, in order to make the language easier to understand. The word "client" generally refers to the caller of an RPC, or the importer of a stub. The word "server" refers to the callee, or the exporter. This is merely a convention to make explanations more natural.
2626

27+
## Transport and Framing
28+
29+
The protocol operates on a bidirectional stream of discrete messages. Each message is a single JSON value (typically an array). The protocol does not define how messages are framed on the wire; this is the responsibility of the transport layer.
30+
31+
For transports that natively provide message framing (e.g. WebSocket or MessagePort), each transport-level message corresponds to exactly one RPC message.
32+
33+
The built-in HTTP transport is newline-delimited, packing a series of messages into a single HTTP request or response body. Each message is serialized as a single line of JSON (no embedded newlines), and messages are separated by a newline character (`\n`). An empty body is interpreted as zero messages.
34+
35+
Other transports are free to use other framing strategies.
36+
2737
## Imports and Exports
2838

2939
Each side of an RPC session maintains two tables: imports and exports. One side's exports correspond to the other side's imports. Imports and exports are assigned sequential numeric IDs. However, in some cases an ID needs to be chosen by the importing side, and in some cases by the exporting side. In order to avoid conflicts:

0 commit comments

Comments
 (0)