Writer returns a writer bounded by the context that will write a WebSocket message of type dataType to the connection. You must close the writer once you have written the entire message. Only one writer can be open at a time, multiple calls will block until the previous writer is closed.
(ctx context.Context, typ MessageType)
| 27 | // Only one writer can be open at a time, multiple calls will block until the previous writer |
| 28 | // is closed. |
| 29 | func (c *Conn) Writer(ctx context.Context, typ MessageType) (io.WriteCloser, error) { |
| 30 | w, err := c.writer(ctx, typ) |
| 31 | if err != nil { |
| 32 | return nil, fmt.Errorf("failed to get writer: %w", err) |
| 33 | } |
| 34 | return w, nil |
| 35 | } |
| 36 | |
| 37 | // Write writes a message to the connection. |
| 38 | // |