rooms

package
v0.0.0-...-889eed4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CachedResults controls the amount of results cached per room that is sent upon reconnect
	CachedResults = 10
	// RoomIdleTime determines when a room is being closed once all members left
	RoomIdleTime = 60 * time.Second
)
View Source
const (
	// AddRollerErrorRoomNonExistent will be thrown if the room where we tried to add ourselves is non existent
	AddRollerErrorRoomNonExistent = iota
)

Variables

View Source
var (
	// RoomsGauge keeps track of all the active rooms
	RoomsGauge = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "wuerfler_rooms",
		Help: "Active rooms",
	})
)

Functions

This section is empty.

Types

type AddRollerError

type AddRollerError struct {
	Type int
	// contains filtered or unexported fields
}

AddRollerError is an error thrown when trying to add rollers to a room

func NewAddRollerError

func NewAddRollerError(t int) *AddRollerError

NewAddRollerError creates a new AddRollerError

func (*AddRollerError) Error

func (e *AddRollerError) Error() string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages rooms

func NewManager

func NewManager(log *log.Logger) *Manager

NewManager creates a new manager

func (*Manager) AddRoller

func (m *Manager) AddRoller(roomName string, name string) (Roller, error)

AddRoller adds a new roller to a room

func (*Manager) CreateRoom

func (m *Manager) CreateRoom(name string) (string, error)

CreateRoom creates a new room and returns the new name

func (*Manager) Exists

func (m *Manager) Exists(roomName string) bool

Exists checks if a roomName exists

type ProfileUpdateRequest

type ProfileUpdateRequest struct {
	OldName string
	NewName string
}

ProfileUpdateRequest is the input data when somebody tries to change their name

type RollRequest

type RollRequest struct {
	Name  string
	Dices []uint8
}

RollRequest is the request to roll some dices

type RollResult

type RollResult struct {
	Dice   uint8 `json:"dice"`
	Result uint8 `json:"result"`
}

RollResult is the result of one dice

type RollResults

type RollResults struct {
	Name    string       `json:"name"`
	Date    time.Time    `json:"date"`
	Results []RollResult `json:"results"`
}

RollResults is the result of several dices of a roller

type Roller

type Roller struct {
	Name            string
	RollRequestChan chan []uint8
	ProfileUpdate   chan string
	RollResultsChan chan RollResults
	UsersUpdate     chan UsersUpdateInfo
	RemoveSelf      chan struct{}
}

Roller is our User object

func NewRoller

func NewRoller(name string) Roller

NewRoller creates a new Roller

type Room

type Room struct {
	// contains filtered or unexported fields
}

Room holds everything room related

func NewRoom

func NewRoom(name string) Room

NewRoom creates a new room

type UsersUpdateInfo

type UsersUpdateInfo struct {
	Self   string   `json:"self"`
	Others []string `json:"others"`
}

UsersUpdateInfo will be sent whenevert something changed regarding to usernames or so on the backend (join, leave, name change)

Jump to

Keyboard shortcuts

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