Documentation ¶
Index ¶
- func CreateDispatchKey(t EventType, condition EventCondition) string
- type AckPayload
- type AnyPayload
- type BridgedCommandBody
- type ChangeField
- type ChangeFieldType
- type ChangeMap
- type CloseCode
- type DispatchOptions
- type DispatchPayload
- type EmptyObject
- type EndOfStreamPayload
- type ErrorPayload
- type EventCondition
- type EventType
- type EventsInst
- type HeartbeatPayload
- type HelloPayload
- type HelloPayloadInstanceInfo
- type Instance
- type Message
- type Opcode
- type ReconnectPayload
- type ResumePayload
- type SessionEffect
- type SessionMutation
- type SessionMutationEvent
- type SignalPayload
- type SignalUser
- type SubscribePayload
- type UnsubscribePayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDispatchKey ¶
func CreateDispatchKey(t EventType, condition EventCondition) string
Types ¶
type AckPayload ¶
type AckPayload struct { Command string `json:"command"` Data json.RawMessage `json:"data"` }
type AnyPayload ¶
type AnyPayload interface { json.RawMessage | HelloPayload | AckPayload | HeartbeatPayload | ReconnectPayload | ResumePayload | SubscribePayload | UnsubscribePayload | DispatchPayload | SignalPayload | ErrorPayload | EndOfStreamPayload | BridgedCommandBody }
type BridgedCommandBody ¶
type BridgedCommandBody struct { Platform structures.UserConnectionPlatform `json:"platform"` Identifiers []string `json:"identifiers"` Kinds []structures.CosmeticKind `json:"kinds"` }
type ChangeField ¶
type ChangeField struct { Key string `json:"key"` Index *int32 `json:"index"` Nested bool `json:"nested,omitempty"` Type ChangeFieldType `json:"type"` OldValue any `json:"old_value,omitempty"` Value any `json:"value"` }
func (ChangeField) String ¶
func (cf ChangeField) String() string
type ChangeFieldType ¶
type ChangeFieldType string
const ( ChangeFieldTypeString ChangeFieldType = "string" ChangeFieldTypeNumber ChangeFieldType = "number" ChangeFieldTypeBool ChangeFieldType = "bool" ChangeFieldTypeObject ChangeFieldType = "object" )
type ChangeMap ¶
type ChangeMap struct { // The object's ID ID primitive.ObjectID `json:"id"` // The type of the object Kind structures.ObjectKind `json:"kind"` // Contextual is whether or not this event is only relating // to the specific source conditions and not indicative of a // genuine creation, deletion, or update to the object Contextual bool `json:"contextual,omitempty"` // The user who made changes to the object Actor model.UserPartialModel `json:"actor,omitempty"` // 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 list of items pushed to an array Pushed []ChangeField `json:"pushed,omitempty"` // A list of items pulled from an array Pulled []ChangeField `json:"pulled,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 CloseCodeReconnect CloseCode = 4012 // the client should reconnect )
type DispatchOptions ¶
type DispatchOptions struct { Delay time.Duration Whisper string Effect *SessionEffect DisableDedupe bool }
type DispatchPayload ¶
type DispatchPayload struct { Type EventType `json:"type"` // Detailed changes to an object Body ChangeMap `json:"body"` // Hash is a hash of the target object, used for deduping Hash *uint32 `json:"hash,omitempty"` // A list of effects to apply to the session when this dispatch is received Effect *SessionEffect `json:"effect,omitempty"` // A list of subscriptions that match this dispatch Matches []uint32 `json:"matches,omitempty"` // A list of conditions where at least one must have all its fields match a subscription in order for this dispatch to be delivered Conditions []EventCondition `json:"condition,omitempty"` // This dispatch is a whisper to a specific session, usually as a response to a command Whisper string `json:"whisper,omitempty"` }
type EmptyObject ¶
type EmptyObject = struct{}
type EndOfStreamPayload ¶
type ErrorPayload ¶
type EventCondition ¶
func (EventCondition) Match ¶
func (evc EventCondition) Match(other EventCondition) bool
func (EventCondition) Set ¶
func (evc EventCondition) Set(key string, value string) EventCondition
func (EventCondition) SetObjectID ¶
func (evc EventCondition) SetObjectID(id primitive.ObjectID) EventCondition
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" EventTypeAnyEntitlement EventType = "entitlement.*" EventTypeCreateEntitlement EventType = "entitlement.create" EventTypeUpdateEntitlement EventType = "entitlement.update" EventTypeDeleteEntitlement EventType = "entitlement.delete" EventTypeAnyCosmetic EventType = "cosmetic.*" EventTypeCreateCosmetic EventType = "cosmetic.create" EventTypeUpdateCosmetic EventType = "cosmetic.update" EventTypeDeleteCosmetic EventType = "cosmetic.delete" EventTypeWhisper EventType = "whisper.self" )
func (EventType) ObjectName ¶
type EventsInst ¶
type EventsInst struct {
// contains filtered or unexported fields
}
func (*EventsInst) Dispatch ¶
func (inst *EventsInst) Dispatch(t EventType, cm ChangeMap, cond ...EventCondition)
func (*EventsInst) DispatchWithEffect ¶
func (inst *EventsInst) DispatchWithEffect(t EventType, cm ChangeMap, opt DispatchOptions, cond ...EventCondition) Message[DispatchPayload]
type HeartbeatPayload ¶
type HeartbeatPayload struct {
Count uint64 `json:"count"`
}
type HelloPayload ¶
type Instance ¶
type Instance interface { Dispatch(t EventType, cm ChangeMap, cond ...EventCondition) DispatchWithEffect(t EventType, cm ChangeMap, opt DispatchOptions, cond ...EventCondition) Message[DispatchPayload] }
func NewPublisher ¶
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 = 37 // S - Emit a spectator signal OpcodeBridge Opcode = 38 // S - Send a special command )
func (Opcode) PublishKey ¶
type ReconnectPayload ¶
type ReconnectPayload struct {
Reason string `json:"reason"`
}
type ResumePayload ¶
type ResumePayload struct {
SessionID string `json:"session_id"`
}
type SessionEffect ¶
type SessionEffect struct { AddSubscriptions []SubscribePayload `json:"add_subscriptions,omitempty"` RemoveSubscriptions []UnsubscribePayload `json:"remove_subscriptions,omitempty"` RemoveHashes []uint32 `json:"remove_hashes,omitempty"` }
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 ¶
Click to show internal directories.
Click to hide internal directories.