Documentation ¶
Index ¶
- Variables
- type BaseEvent
- type Event
- func ConvertProtoEvent(protoEvent *roomsv1.Event) (Event, error)
- func NewEvent(baseEvent BaseEvent) (Event, error)
- func NewGenericEvent(eventType EventType, roomId string, description string) Event
- func NewGenericEventWithTimestamp(timestamp time.Time, eventType EventType, roomId string, description string) Event
- func NewRoomEditedEvent(roomId string, roomName string, maxPlayers uint32, questionCount uint32, ...) Event
- func NewRoomStartingEvent(roomId string, description string, questionSetId string) Event
- func NewUserEvent(eventType EventType, roomId string, userId string, description string) Event
- type EventType
- type GenericEvent
- type Room
- type RoomEditedEvent
- type RoomStartingEvent
- type RoomStatus
- type UserEvent
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownEventType error = errors.New("unknown event type")
var ProtoStatusMap = map[roomsv1.RoomStatus]RoomStatus{ roomsv1.RoomStatus_ROOM_STATUS_WAITING: Waiting, roomsv1.RoomStatus_ROOM_STATUS_STARTING: Starting, roomsv1.RoomStatus_ROOM_STATUS_PLAYING: Playing, roomsv1.RoomStatus_ROOM_STATUS_ENDING: Ending, }
Map to convert a connectrpc room status to a model.RoomStatus
Functions ¶
This section is empty.
Types ¶
type BaseEvent ¶
type BaseEvent struct { ID ulid.ULID Timestamp time.Time Type EventType RoomID string Description string }
BaseEvent struct with embedded fields
func (*BaseEvent) GetDescription ¶
func (*BaseEvent) GetTimestamp ¶
type Event ¶
type Event interface { GetID() string GetTimestamp() time.Time GetType() EventType GetDescription() string GetRoomID() string }
Event interface definition
func ConvertProtoEvent ¶ added in v0.6.5
ConvertProtoEvent converts the room event type from the ConnectRPC format back to the internal event format.
Returns ErrEventTypeInvalid if the event is malformed.
Returns ErrUlidInvalid if the event id can't be parsed as an ULID.
func NewGenericEvent ¶
Factory function for creating a new GenericEvent
func NewGenericEventWithTimestamp ¶ added in v0.7.2
func NewGenericEventWithTimestamp(timestamp time.Time, eventType EventType, roomId string, description string) Event
Factory function for creating a new GenericEvent. This function is useful for synchronizing the event with other functions.
func NewRoomEditedEvent ¶ added in v0.10.0
func NewRoomEditedEvent(roomId string, roomName string, maxPlayers uint32, questionCount uint32, playingDuration time.Duration) Event
Factory function to create a new RoomEditedEvent
func NewRoomStartingEvent ¶ added in v0.7.0
type Room ¶
type Room struct { ID string `validate:"bingame_room_id"` Name string `validate:"max=50" redis:"name"` HostID string `validate:"required,uuid5" redis:"hostid"` MaxPlayers uint32 `validate:"required,min=1,max=40" redis:"maxplayers"` QuestionCount uint32 `validate:"required,min=1,max=1000" redis:"questioncount"` Status RoomStatus `redis:"status"` LastTimeStarted *time.Time `redis:"laststarted"` // is nil if the room never started QuestionSetID string `validate:"omitempty,uuid4" redis:"questionset"` FinishedAnsweringCount uint32 `redis:"finishedanswering" validate:"ltefield=MaxPlayers"` PlayingDuration time.Duration `redis:"playingdurationseconds" validate:"min=30s"` }
type RoomEditedEvent ¶ added in v0.10.0
type RoomEditedEvent struct { BaseEvent RoomName string MaxPlayers uint32 PlayingDuration time.Duration }
func (*RoomEditedEvent) GetMaxPlayers ¶ added in v0.10.0
func (e *RoomEditedEvent) GetMaxPlayers() uint32
func (*RoomEditedEvent) GetPlayingDuration ¶ added in v0.10.0
func (e *RoomEditedEvent) GetPlayingDuration() time.Duration
func (*RoomEditedEvent) GetRoomName ¶ added in v0.10.0
func (e *RoomEditedEvent) GetRoomName() string
type RoomStartingEvent ¶ added in v0.7.0
func (*RoomStartingEvent) GetQuestionSetId ¶ added in v0.7.0
func (e *RoomStartingEvent) GetQuestionSetId() string
func (*RoomStartingEvent) GetStartsIn ¶ added in v0.7.0
func (e *RoomStartingEvent) GetStartsIn() time.Duration
type RoomStatus ¶
type RoomStatus int
const ( Waiting RoomStatus = iota Starting Playing Ending )
statuses of the room
func ConvertProtoStatus ¶ added in v0.6.5
func ConvertProtoStatus(protoStatus roomsv1.RoomStatus) (RoomStatus, error)
ConvertProtoStatus converts the room status type from the ConnectRPC format back to the internal model format.
Returns ErrRoomStatusInvalid if the status is not recognized.