state

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStopIter error

ErrStopIter is a copy of gotrix.ErrStopIter.

Functions

This section is empty.

Types

type DefaultState

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

DefaultState is the default used implementation of state by the gotrix package.

func NewDefault

func NewDefault() *DefaultState

NewDefault returns a DefaultState that has been initialized empty.

func (*DefaultState) AddEvents added in v0.3.0

func (d *DefaultState) AddEvents(sync *api.SyncResponse) error

AddEvents sets the room state events inside a DefaultState to be returned by DefaultState later.

func (*DefaultState) EachRoomState added in v0.3.0

func (d *DefaultState) EachRoomState(id matrix.RoomID, typ event.Type, f func(string, event.StateEvent) error) error

EachRoomState calls f for every event of the specified type. It terminates iteration when an error is returned. Use ErrStopIter to denote a non-failure condition. It makes a copy internally and calls f on it.

func (*DefaultState) RoomState

func (d *DefaultState) RoomState(roomID matrix.RoomID, eventType event.Type, key string) (event.StateEvent, error)

RoomState returns the last event added in AddEvents. It never returns an error as it does not forget state.

func (*DefaultState) RoomStates

func (d *DefaultState) RoomStates(roomID matrix.RoomID, eventType event.Type) (map[string]event.StateEvent, error)

RoomStates returns the last set of events added in AddEvents.

func (*DefaultState) RoomSummary added in v0.3.0

func (d *DefaultState) RoomSummary(roomID matrix.RoomID) (api.SyncRoomSummary, error)

RoomSummary returns the summaries set in AddEvents.

type RoomState

type RoomState map[event.Type]map[string]event.StateEvent

RoomState is the state kept by a DefaultState for each room.

Jump to

Keyboard shortcuts

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