handler

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

func New

func New() *Registry

New creates a new handler registry.

func (*Registry) AddEvents

func (r *Registry) AddEvents(sync *api.SyncResponse) error

AddEvents satisfies part of gotrix.State.

func (*Registry) OnSync

func (r *Registry) OnSync(f func(*api.SyncResponse)) func()

OnSync is called after the state updates on every sync.

func (*Registry) OnSyncCh

func (r *Registry) OnSyncCh(ctx context.Context, ch chan<- *api.SyncResponse)

OnSyncCh sends into the channel every sync until the returned callback is called.

func (*Registry) SubscribeAllTimeline

func (r *Registry) SubscribeAllTimeline(f interface{}) func()

SubscribeAllTimeline subscribes to the timeline of all rooms.

func (*Registry) SubscribeRoom

func (r *Registry) SubscribeRoom(rID matrix.RoomID, typ event.Type, f interface{}) func()

SubscribeRoom subscribes the given function to a room's state and ephemeral event.

func (*Registry) SubscribeRoomEvents

func (r *Registry) SubscribeRoomEvents(
	rID matrix.RoomID, types []event.Type, f interface{}) func()

SubscribeRoomEvents is like SubscribeRoom but registers multiple events at once.

func (*Registry) SubscribeRoomStateKey

func (r *Registry) SubscribeRoomStateKey(
	rID matrix.RoomID, typ event.Type, key string, f interface{}) func()

SubscribeRoomStateKey is similarly to SubscribeRoom, except it only filters for the given state key.

func (*Registry) SubscribeRoomSync

func (r *Registry) SubscribeRoomSync(rID matrix.RoomID, f func()) func()

SubscribeRoomSync subscribes f to be called every time the room is synced.

func (*Registry) SubscribeTimeline

func (r *Registry) SubscribeTimeline(rID matrix.RoomID, f interface{}) func()

SubscribeTimeline subscribes the given function to the timeline of a room. If the returned callback is called, then the room is removed from the handlers.

func (*Registry) SubscribeTimelineSync

func (r *Registry) SubscribeTimelineSync(rID matrix.RoomID, f interface{}) func()

SubscribeTimelineSync is similar to SubscribeTimeline, except f is only called on the latest event each sync instead of on all of them.

func (*Registry) SubscribeUser

func (r *Registry) SubscribeUser(typ event.Type, f interface{}) func()

SubscribeUser subscribes the given function with the given event type to be called on each user event. If typ is "*", then all events are called w/ it.

func (*Registry) Wrap

func (r *Registry) Wrap(state gotrix.State) gotrix.State

Wrap returns a state wrapper that wraps the existing gotrix.State to also call Registry.

Jump to

Keyboard shortcuts

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