NewEncoder creates a JSON-over websocket encoder for the type T, which must be JSON-serializable. You may then call Encode() to send objects over the websocket. Creating an Encoder closes the websocket for reading, turning it into a unidirectional write stream of JSON-encoded objects.
(conn *websocket.Conn, typ websocket.MessageType)
| 37 | // You may then call Encode() to send objects over the websocket. Creating an Encoder closes the |
| 38 | // websocket for reading, turning it into a unidirectional write stream of JSON-encoded objects. |
| 39 | func NewEncoder[T any](conn *websocket.Conn, typ websocket.MessageType) *Encoder[T] { |
| 40 | // Here we close the websocket for reading, so that the websocket library will handle pings and |
| 41 | // close frames. |
| 42 | _ = conn.CloseRead(context.Background()) |
| 43 | return &Encoder[T]{conn: conn, typ: typ} |
| 44 | } |
no outgoing calls
no test coverage detected