Read is a convenience method around Reader to read a single message from the connection.
(ctx context.Context)
| 39 | // Read is a convenience method around Reader to read a single message |
| 40 | // from the connection. |
| 41 | func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) { |
| 42 | typ, r, err := c.Reader(ctx) |
| 43 | if err != nil { |
| 44 | return 0, nil, err |
| 45 | } |
| 46 | |
| 47 | b, err := io.ReadAll(r) |
| 48 | return typ, b, err |
| 49 | } |
| 50 | |
| 51 | // CloseRead starts a goroutine to read from the connection until it is closed |
| 52 | // or a data message is received. |