MCPcopy Index your code
hub / github.com/anomalyco/opencode / encodeEvent

Function encodeEvent

packages/http-recorder/src/socket.ts:34–37  ·  view source on GitHub ↗
(direction: "client" | "server", message: Frame)

Source from the content-addressed store, hash-verified

32type Frame = string | Uint8Array
33
34const encodeEvent = (direction: "client" | "server", message: Frame): WebSocketEvent =>
35 typeof message === "string"
36 ? { direction, kind: "text", body: message }
37 : { direction, kind: "binary", body: Buffer.from(message).toString("base64"), bodyEncoding: "base64" }
38
39const decodeEvent = (event: WebSocketEvent): Frame =>
40 event.kind === "text" ? event.body : new Uint8Array(Buffer.from(event.body, "base64"))

Callers 2

makeRecordingSocketFunction · 0.85
makeReplaySocketFunction · 0.85

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected