Created
September 10, 2022 06:13
-
-
Save percybolmer/8242ccab9fc5dc2da7942faca3b37964 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "encoding/json" | |
// Event is the Messages sent over the websocket | |
// Used to differ between different actions | |
type Event struct { | |
// Type is the message type sent | |
Type string `json:"type"` | |
// Payload is the data Based on the Type | |
Payload json.RawMessage `json:"payload"` | |
} | |
// EventHandler is a function signature that is used to affect messages on the socket and triggered | |
// depending on the type | |
type EventHandler func(event Event, c *Client) error | |
const ( | |
// EventSendMessage is the event name for new chat messages sent | |
EventSendMessage = "send_message" | |
) | |
// SendMessageEvent is the payload sent in the | |
// send_message event | |
type SendMessageEvent struct { | |
Message string `json:"message"` | |
From string `json:"from"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment