event

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2025 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package event defines event types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeOrPanic

func EncodeOrPanic(v any) []byte

EncodeOrPanic is a helper function to encode a JSON payload on the fly skipping the error check. Panics if the error occurs.

Types

type EventAction

type EventAction int

EventAction is a domain of possible actions. The core server can declare custom event action.

const (
	// Server events.
	CLIENTS_COUNTER EventAction = iota
	ADD_CLIENT
	REMOVE_CLIENT
	REDIRECT
	ADD_ROOM
	REMOVE_ROOM
	UPDATE_ROOM

	// Client events.
	CHAT
)

type ExternalEvent

type ExternalEvent struct {
	// Concrette payload type depends on event action.
	Payload  json.RawMessage `json:"p"`
	ClientId string          `json:"-"`
	RoomId   string          `json:"-"`
	Action   EventAction     `json:"a"`
}

ExternalEvent represents an event type which is exchanged between the Gatekeeper and clients.

type InternalEvent

type InternalEvent struct {
	// Concrette payload type depends on event action.
	Payload json.RawMessage `json:"p"`
	// Sender id.
	ClientId string `json:"cid"`
	// Room which will recieve an event.
	RoomId string      `json:"rid"`
	Action EventAction `json:"a"`
}

InternalEvent represents an event type which is exchanged between the Gatekeeper and the core server. Internal event contains metadata which helps to identify the sender and route the room which will handle it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL