MCPcopy
hub / github.com/coder/websocket / CloseRead

Method CloseRead

ws_js.go:393–413  ·  view source on GitHub ↗

CloseRead implements *Conn.CloseRead for wasm.

(ctx context.Context)

Source from the content-addressed store, hash-verified

391
392// CloseRead implements *Conn.CloseRead for wasm.
393func (c *Conn) CloseRead(ctx context.Context) context.Context {
394 c.closeReadMu.Lock()
395 ctx2 := c.closeReadCtx
396 if ctx2 != nil {
397 c.closeReadMu.Unlock()
398 return ctx2
399 }
400 ctx, cancel := context.WithCancel(ctx)
401 c.closeReadCtx = ctx
402 c.closeReadMu.Unlock()
403
404 go func() {
405 defer cancel()
406 defer c.CloseNow()
407 _, _, err := c.read(ctx)
408 if err != nil {
409 c.Close(StatusPolicyViolation, "unexpected data message")
410 }
411 }()
412 return ctx
413}
414
415// SetReadLimit implements *Conn.SetReadLimit for wasm.
416func (c *Conn) SetReadLimit(n int64) {

Callers

nothing calls this directly

Calls 4

CloseNowMethod · 0.95
readMethod · 0.95
CloseMethod · 0.95
LockMethod · 0.45

Tested by

no test coverage detected