wsbridge

package
v0.51.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package wsbridge bidirectionally forwards WebSocket frames between two connections. Frame-level forwarding: doesn't parse JSON-RPC. JSON-RPC envelope boundaries are preserved because each Read/Write pair transfers exactly one frame — never byte concatenation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeepAlive added in v0.51.2

func KeepAlive(ctx context.Context, conn *websocket.Conn, interval time.Duration)

KeepAlive sends a ws ping on conn every interval until ctx is cancelled. Exported so the codex-exec-gateway /bridge and inbound handlers (which run their own custom pumps and don't go through RunProxy) can install the same anti-idle behavior.

func PumpFrames

func PumpFrames(ctx context.Context, src, dst *websocket.Conn) error

PumpFrames reads one frame at a time from src and writes the exact same (MessageType, payload) to dst. This preserves JSON-RPC envelope boundaries.

Returns nil when src closes cleanly; otherwise the underlying error.

func RunProxy

func RunProxy(ctx context.Context, a, b *websocket.Conn, onFrame func()) error

RunProxy starts two pumps in parallel and returns when either side closes or errors. Both ws conns are left open for the caller to close. onFrame is called on every successfully read frame (from either direction); pass nil if no callback is needed.

A background ping is sent on `a` every keepAliveInterval to keep idle-killing middleboxes from severing the connection during long quiet periods (e.g. the LLM taking minutes to respond before any frame flows).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL