CloseRead implements *Conn.CloseRead for wasm.
(ctx context.Context)
| 391 | |
| 392 | // CloseRead implements *Conn.CloseRead for wasm. |
| 393 | func (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. |
| 416 | func (c *Conn) SetReadLimit(n int64) { |