WriteEvent will write a Event type message to the websocket connection.
(c *websocket.Conn, ctx context.Context, event any)
| 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 { |
| 291 | payload, err := json.Marshal(event) |
| 292 | if err != nil { |
| 293 | return err |
| 294 | } |
| 295 | return c.Write(ctx, websocket.MessageText, payload) |
| 296 | } |
| 297 | |
| 298 | // IsClosed returns true if the websocket error is a websocket.CloseError; returns false if not a |
| 299 | // websocket.CloseError |