MCPcopy Index your code
hub / github.com/coder/coder / WebsocketNetConn

Function WebsocketNetConn

codersdk/websocket.go:43–53  ·  view source on GitHub ↗

WebsocketNetConn wraps websocket.NetConn and returns a context that is tied to the parent context and the lifetime of the conn. Any error during read or write will cancel the context, but not close the conn. Close should be called to release context resources.

(ctx context.Context, conn *websocket.Conn, msgType websocket.MessageType)

Source from the content-addressed store, hash-verified

41// during read or write will cancel the context, but not close the
42// conn. Close should be called to release context resources.
43func WebsocketNetConn(ctx context.Context, conn *websocket.Conn, msgType websocket.MessageType) (context.Context, net.Conn) {
44 // Set the read limit to 4 MiB -- about the limit for protobufs. This needs to be larger than
45 // the default because some of our protocols can include large messages like startup scripts.
46 conn.SetReadLimit(1 << 22)
47 ctx, cancel := context.WithCancel(ctx)
48 nc := websocket.NetConn(ctx, conn, msgType)
49 return ctx, &wsNetConn{
50 cancel: cancel,
51 Conn: nc,
52 }
53}

Calls

no outgoing calls