Documentation ¶
Index ¶
- func Publish[D AnyPayload](ctx context.Context, msg Message[D], redis redis.Instance) error
- type AckPayload
- type AnyPayload
- type ChangeField
- type ChangeMap
- type CloseCode
- type DispatchPayload
- type EmptyObject
- type EndOfStreamPayload
- type ErrorPayload
- type EventType
- type HeartbeatPayload
- type HelloPayload
- type Message
- type Opcode
- type SessionMutation
- type SessionMutationEvent
- type SignalPayload
- type SignalUser
- type SubscribePayload
- type UnsubscribePayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AckPayload ¶
type AnyPayload ¶
type AnyPayload interface { json.RawMessage | HelloPayload | AckPayload | HeartbeatPayload | SubscribePayload | UnsubscribePayload | DispatchPayload | SignalPayload | ErrorPayload | EndOfStreamPayload }
type ChangeField ¶
type ChangeMap ¶
type ChangeMap struct { // The object's ID ID primitive.ObjectID `json:"id"` // The type of the object Kind structures.ObjectKind `json:"kind"` // A list of added fields Added []ChangeField `json:"added,omitempty"` // A list of updated fields Updated []ChangeField `json:"updated,omitempty"` // A list of removed fields Removed []ChangeField `json:"removed,omitempty"` // A full object. Only available during a "create" event Object json.RawMessage `json:"object,omitempty"` }
type CloseCode ¶
type CloseCode uint16
const ( CloseCodeServerError CloseCode = 4000 // an error occured on the server's end CloseCodeUnknownOperation CloseCode = 4001 // the client sent an unexpected opcode CloseCodeInvalidPayload CloseCode = 4002 // the client sent a payload that couldn't be decoded CloseCodeAuthFailure CloseCode = 4003 // the client unsucessfully tried to identify CloseCodeAlreadyIdentified CloseCode = 4004 // the client wanted to identify again CloseCodeRateLimit CloseCode = 4005 // the client is being rate-limited CloseCodeRestart CloseCode = 4006 // the server is restarting and the client should reconnect CloseCodeMaintenance CloseCode = 4007 // the server is in maintenance mode and not accepting connections CloseCodeTimeout CloseCode = 4008 // the client was idle for too long CloseCodeAlreadySubscribed CloseCode = 4009 // the client tried to subscribe to an event twice CloseCodeNotSubscribed CloseCode = 4010 // the client tried to unsubscribe from an event they weren't subscribing to CloseCodeInsufficientPrivilege CloseCode = 4011 // the client did something that they did not have permission for )
type DispatchPayload ¶
type EmptyObject ¶
type EmptyObject = struct{}
type EndOfStreamPayload ¶
type ErrorPayload ¶
type EventType ¶
type EventType string
const ( EventTypeAnySystem EventType = "system.*" EventTypeSystemAnnouncement EventType = "system.announcement" EventTypeAnyEmote EventType = "emote.*" EventTypeCreateEmote EventType = "emote.create" EventTypeUpdateEmote EventType = "emote.update" EventTypeDeleteEmote EventType = "emote.delete" EventTypeAnyEmoteSet EventType = "emote_set.*" EventTypeCreateEmoteSet EventType = "emote_set.create" EventTypeUpdateEmoteSet EventType = "emote_set.update" EventTypeDeleteEmoteSet EventType = "emote_set.delete" EventTypeAnyUser EventType = "user.*" EventTypeCreateUser EventType = "user.create" EventTypeUpdateUser EventType = "user.update" EventTypeDeleteUser EventType = "user.delete" EventTypeAddUserConnection EventType = "user.add_connection" EventTypeUpdateUserConnection EventType = "user.update_connection" EventTypeDeleteUserConnection EventType = "user.delete_connection" )
func (EventType) ObjectName ¶
type HeartbeatPayload ¶
type HeartbeatPayload struct {
Count int64 `json:"count"`
}
type HelloPayload ¶
type Message ¶
type Message[D AnyPayload] struct { Op Opcode `json:"op"` Timestamp int64 `json:"t"` Data D `json:"d"` Sequence uint64 `json:"s,omitempty"` }
func ConvertMessage ¶
func ConvertMessage[D AnyPayload](c Message[json.RawMessage]) (Message[D], error)
func NewMessage ¶
func NewMessage[D AnyPayload](op Opcode, data D) Message[D]
type Opcode ¶
type Opcode uint8
const ( // Default ops (0-32) OpcodeDispatch Opcode = 0 // R - Server dispatches data to the client OpcodeHello Opcode = 1 // R - Server greets the client OpcodeHeartbeat Opcode = 2 // R - Keep the connection alive OpcodeReconnect Opcode = 4 // R - Server demands that the client reconnects OpcodeAck Opcode = 5 // R - Acknowledgement of an action OpcodeError Opcode = 6 // R - Extra error context in cases where the closing frame is not enough OpcodeEndOfStream Opcode = 7 // R - The connection's data stream is ending // Commands (33-64) OpcodeIdentify Opcode = 33 // S - Authenticate the session OpcodeResume Opcode = 34 // S - Resume the previous session and receive missed events OpcodeSubscribe Opcode = 35 // S - Subscribe to an event OpcodeUnsubscribe Opcode = 36 // S - Unsubscribe from an event OpcodeSignal Opcode = 36 // S - Emit a spectator signal )
func (Opcode) PublishKey ¶
type SessionMutation ¶
type SessionMutation struct { RequestID string `json:"request_id"` SessionID string `json:"session_id"` Events []SessionMutationEvent `json:"events,omitempty"` ActorID primitive.ObjectID `json:"actor_id,omitempty"` }
type SessionMutationEvent ¶
type SignalPayload ¶
type SignalPayload struct { Sender SignalUser `json:"sender"` Host SignalUser `json:"host"` }
type SignalUser ¶
type SubscribePayload ¶
type UnsubscribePayload ¶
type UnsubscribePayload struct {
Type EventType `json:"type"`
}
Click to show internal directories.
Click to hide internal directories.