Documentation
¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func Bridge ¶
Bridge copies data bidirectionally between a yamux stream and a TCP connection until one side closes or ctx is cancelled. Both connections are closed when Bridge returns.
func ReadStatus ¶
ReadStatus reads a single status byte from r.
func WriteConnectHeader ¶
WriteConnectHeader writes a connect header to w.
Types ¶
type ConnectHeader ¶
ConnectHeader is the first message sent on each yamux stream by the client.
func ReadConnectHeader ¶
func ReadConnectHeader(r io.Reader) (ConnectHeader, error)
ReadConnectHeader reads a connect header from r.
type WSAdapter ¶
type WSAdapter struct {
// contains filtered or unexported fields
}
WSAdapter wraps a *websocket.Conn to implement io.ReadWriteCloser, bridging gorilla/websocket's message-based API to the byte-stream interface that yamux requires.
func NewWSAdapter ¶
NewWSAdapter creates a new adapter around the given WebSocket connection.
func (*WSAdapter) Read ¶
Read implements io.Reader. It buffers partially-read WebSocket messages so callers can read arbitrary byte counts.
Read is NOT safe for concurrent use. This is intentional: yamux guarantees a single reader goroutine (recvLoop). Write uses mu because yamux writes from multiple goroutines (data, pings, window updates).
Do NOT add a mutex here. Close() must be callable concurrently to unblock a NextReader() blocked on the connection. If Read held a mutex that Close also acquired, Close would deadlock waiting for Read, while Read is blocked on NextReader waiting for Close to shut the connection.