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

Function echoWebSocket

packages/opencode/test/server/workspace-proxy.test.ts:44–59  ·  view source on GitHub ↗
(request: HttpServerRequest.HttpServerRequest)

Source from the content-addressed store, hash-verified

42}
43
44function echoWebSocket(request: HttpServerRequest.HttpServerRequest) {
45 return Effect.gen(function* () {
46 const socket = yield* Effect.orDie(request.upgrade)
47 const write = yield* socket.writer
48 // The upstream announces the negotiated protocol, then echoes every
49 // received frame. The assertions use those messages to prove proxy flow.
50 yield* socket
51 .runRaw((message) => write(`echo:${String(message)}`), {
52 onOpen: write(`protocol:${request.headers["sec-websocket-protocol"] ?? "none"}`).pipe(
53 Effect.catch(() => Effect.void),
54 ),
55 })
56 .pipe(Effect.catch(() => Effect.void))
57 return HttpServerResponse.empty()
58 })
59}
60
61describe("HttpApi workspace proxy", () => {
62 it.live("proxies HTTP request and returns streamed response with status and headers", () =>

Callers

nothing calls this directly

Calls 1

writeFunction · 0.50

Tested by

no test coverage detected