readMessage will read a message from the websocket connection and return the payload.
(c *websocket.Conn, ctx context.Context)
| 276 | |
| 277 | // readMessage will read a message from the websocket connection and return the payload. |
| 278 | func readMessage(c *websocket.Conn, ctx context.Context) ([]byte, error) { |
| 279 | messageType, reader, err := c.Reader(ctx) |
| 280 | if err != nil { |
| 281 | return nil, err |
| 282 | } |
| 283 | if messageType != websocket.MessageText { |
| 284 | return nil, errInvalidMessageType |
| 285 | } |
| 286 | return io.ReadAll(reader) |
| 287 | } |
| 288 | |
| 289 | // WriteEvent will write a Event type message to the websocket connection. |
| 290 | func WriteEvent(c *websocket.Conn, ctx context.Context, event any) error { |
no outgoing calls
no test coverage detected