(conn *websocket.Conn, readType, writeType websocket.MessageType, logger slog.Logger)
| 13 | } |
| 14 | |
| 15 | func NewStream[R any, W any](conn *websocket.Conn, readType, writeType websocket.MessageType, logger slog.Logger) *Stream[R, W] { |
| 16 | return &Stream[R, W]{ |
| 17 | conn: conn, |
| 18 | r: NewDecoder[R](conn, readType, logger), |
| 19 | // We intentionally don't call `NewEncoder` because it calls `CloseRead`. |
| 20 | w: &Encoder[W]{conn: conn, typ: writeType}, |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // Chan returns a `chan` that you can read incoming messages from. The returned |
| 25 | // `chan` will be closed when the WebSocket connection is closed. If there is an |
no outgoing calls