MCPcopy
hub / github.com/cloudflare/capnweb / RpcTransport

Interface RpcTransport

src/rpc.ts:13–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 * built-in transports (e.g. for HTTP batch and WebSocket) don't meet your needs.
12 */
13export interface RpcTransport {
14 /**
15 * The encoding level this transport works with. For this interface it is always "string";
16 * it may be omitted. (See `RpcTransportWithCustomEncoding` for the other levels.)
17 */
18 readonly encodingLevel?: "string";
19
20 /**
21 * Sends a message to the other end. May optionally return a promise; if the promise rejects,
22 * the session is aborted.
23 */
24 send(message: string): void | Promise<void>;
25
26 /**
27 * Receives a message sent by the other end.
28 *
29 * If and when the transport becomes disconnected, this will reject. The thrown error will be
30 * propagated to all outstanding calls and future calls on any stubs associated with the session.
31 * If there are no outstanding calls (and none are made in the future), then the error does not
32 * propagate anywhere -- this is considered a "clean" shutdown.
33 */
34 receive(): Promise<string>;
35
36 /**
37 * Indicates that the RPC system has suffered an error that prevents the session from continuing.
38 * The transport should ideally try to send any queued messages if it can, and then close the
39 * connection. (It's not strictly necessary to deliver queued messages, but the last message sent
40 * before abort() is called is often an "abort" message, which communicates the error to the
41 * peer, so if that is dropped, the peer may have less information about what happened.)
42 */
43 abort?(reason: any): void;
44}
45
46/**
47 * Interface for a transport that receives partially encoded JS values instead of JSON strings.

Callers 15

constructorMethod · 0.65
sendMethod · 0.65
sendMethod · 0.65
sendMethod · 0.65
abortMethod · 0.65
sendMethod · 0.65
bun.test.tsFile · 0.65
readLoopMethod · 0.65
index.test.tsFile · 0.65
bun.test.tsFile · 0.65
abortMethod · 0.65

Implementers 7

TestTransport__tests__/index.test.ts
WebSocketTransportsrc/websocket.ts
MessagePortTransportsrc/messageport.ts
ObjectTestTransport__tests__/index.test.ts

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…