handler

package
v0.0.0-...-8d54791 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeartbeatEvent              = "heartbeat"
	HeartbeatListEvent          = "heartbeatList"
	ImportantHeartbeatListEvent = "importantHeartbeatList"
)
View Source
const (
	AutoLoginEvent = "autoLogin"
)
View Source
const (
	ConnectEvent = shadiaosocketio.OnConnection
)
View Source
const (
	DisconnectEvent = shadiaosocketio.OnDisconnection
)
View Source
const (
	ErrorEvent = shadiaosocketio.OnError
)
View Source
const (
	InfoEvent = "info"
)
View Source
const (
	MessageEvent = shadiaosocketio.OnMessage
)
View Source
const (
	MonitorListEvent = "monitorList"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoLogin

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

func NewAutoLogin

func NewAutoLogin(state AutoLoginState) *AutoLogin

NewAutoLogin creates a new AutoLogin handler.

func (*AutoLogin) Callback

func (al *AutoLogin) Callback(ch *shadiaosocketio.Channel) error

Callback is the function that is called when the event is received.

func (*AutoLogin) Event

func (al *AutoLogin) Event() string

Event returns the event name.

func (*AutoLogin) Occurred

func (al *AutoLogin) Occurred() bool

Occurred returns true if the event has occurred, false otherwise. Required in some places to make sure a specific event has been sent before continuing.

func (*AutoLogin) Register

func (al *AutoLogin) Register(h HandlerRegistrator) error

Register registers the handler with the client.

type AutoLoginState

type AutoLoginState interface {
	SetAutoLogin(autoLogin bool) (err error)
	HasSeen(event string) (seen bool)
	MarkSeen(event string)
}

type Connect

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

Connect is a handler for the connect event.

func NewConnect

func NewConnect(state ConnectState) *Connect

NewConnect returns a new Connect handler.

func (*Connect) Callback

func (c *Connect) Callback(ch *shadiaosocketio.Channel) error

Callback handles the event.

func (*Connect) Event

func (c *Connect) Event() string

Event returns the event name.

func (*Connect) Occurred

func (c *Connect) Occurred() bool

Occurred returns true if the event has occurred at least once.

func (*Connect) Register

func (c *Connect) Register(h HandlerRegistrator) error

Register registers the handler.

type ConnectState

type ConnectState interface {
	Connected() (bool, error)
	SetConnected(bool) error
}

type Disconnect

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

Disconnect is a handler for the disconnect event.

func NewDisconnect

func NewDisconnect(state DisconnectState) *Disconnect

NewDisconnect returns a new Disconnect handler.

func (*Disconnect) Callback

func (d *Disconnect) Callback(ch *shadiaosocketio.Channel, reason websocket.CloseError) error

Callback handles the event.

func (*Disconnect) Event

func (d *Disconnect) Event() string

Event returns the event name.

func (*Disconnect) Occurred

func (d *Disconnect) Occurred() bool

Occurred returns true if the event has occurred at least once.

func (*Disconnect) Register

func (d *Disconnect) Register(h HandlerRegistrator) error

Register registers the handler.

type DisconnectState

type DisconnectState interface {
	SetConnected(bool) error
}

type ErrInvalidDataType

type ErrInvalidDataType struct {
	Expected string
	Actual   string
}

func NewErrInvalidDataType

func NewErrInvalidDataType(expected string, actual any) ErrInvalidDataType

func (ErrInvalidDataType) Error

func (e ErrInvalidDataType) Error() string

type Error

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

func NewError

func NewError(state *state.State) *Error

func (*Error) Callback

func (e *Error) Callback(ch *shadiaosocketio.Channel, data any) error

func (*Error) Event

func (e *Error) Event() string

func (*Error) Occurred

func (e *Error) Occurred() bool

func (*Error) Register

func (e *Error) Register(h HandlerRegistrator) error

type HandlerRegistrator

type HandlerRegistrator interface {
	On(string, any) error
}

HandlerRegistrator is an interface that defines the methods that the handler registration requires.

type Heartbeat

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

func NewHeartbeat

func NewHeartbeat(state HeartbeatState) *Heartbeat

func (*Heartbeat) Callback

func (hn *Heartbeat) Callback(h *shadiaosocketio.Channel, data any) error

func (*Heartbeat) Event

func (hn *Heartbeat) Event() string

func (*Heartbeat) Occurred

func (hn *Heartbeat) Occurred() bool

func (*Heartbeat) Register

func (hn *Heartbeat) Register(h HandlerRegistrator) error

type HeartbeatList

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

func NewHeartbeatList

func NewHeartbeatList(state HeartbeatListState) *HeartbeatList

func (*HeartbeatList) Callback

func (hn *HeartbeatList) Callback(h *shadiaosocketio.Channel, id any, result []any, overwrite any) error

func (*HeartbeatList) Event

func (hn *HeartbeatList) Event() string

func (*HeartbeatList) Occurred

func (hn *HeartbeatList) Occurred() bool

func (*HeartbeatList) Register

func (hn *HeartbeatList) Register(h HandlerRegistrator) error

type HeartbeatListState

type HeartbeatListState interface {
	Heartbeats(monitorId int) (beats []state.Heartbeat, err error)
	SetHeartbeats(monitorId int, beats []state.Heartbeat, overwrite bool) (err error)
}

type HeartbeatState

type HeartbeatState interface {
	Heartbeats(monitorId int) (beats []state.Heartbeat, err error)
	AppendHeartbeat(beat *state.Heartbeat) (err error)
}

type ImportantHeartbeatList

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

func (*ImportantHeartbeatList) Callback

func (hn *ImportantHeartbeatList) Callback(h *shadiaosocketio.Channel, id any, result []any, overwrite any) error

func (*ImportantHeartbeatList) Event

func (hn *ImportantHeartbeatList) Event() string

func (*ImportantHeartbeatList) Occurred

func (hn *ImportantHeartbeatList) Occurred() bool

func (*ImportantHeartbeatList) Register

type ImportantHeartbeatListState

type ImportantHeartbeatListState interface {
	ImportantHeartbeats(monitorId int) (beats []state.Heartbeat, err error)
	SetImportantHeartbeats(monitorId int, beats []state.Heartbeat, overwrite bool) (err error)
}

type Info

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

func NewInfo

func NewInfo(state InfoState) *Info

func (*Info) Callback

func (i *Info) Callback(ch *shadiaosocketio.Channel, data any) error

func (*Info) Event

func (i *Info) Event() string

func (*Info) Occurred

func (i *Info) Occurred() bool

func (*Info) Register

func (i *Info) Register(h HandlerRegistrator) error

type InfoState

type InfoState interface {
	Info() (*state.Info, error)
	SetInfo(*state.Info) error
}

type Message

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

func NewMessage

func NewMessage(state *state.State) *Message

func (*Message) Callback

func (m *Message) Callback(ch *shadiaosocketio.Channel, data any) error

func (*Message) Event

func (m *Message) Event() string

func (*Message) Occurred

func (m *Message) Occurred() bool

func (*Message) Register

func (m *Message) Register(h HandlerRegistrator) error

type MonitorList

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

func NewMonitorList

func NewMonitorList(state MonitorState) *MonitorList

func (MonitorList) Callback

func (ml MonitorList) Callback(ch *shadiaosocketio.Channel, data any) error

func (MonitorList) Event

func (ml MonitorList) Event() string

func (MonitorList) Occurred

func (ml MonitorList) Occurred() bool

func (MonitorList) Register

func (ml MonitorList) Register(h HandlerRegistrator) error

type MonitorState

type MonitorState interface {
	SetMonitors(monitors map[int]*state.Monitor) (err error)
	HasSeen(event string) (seen bool)
	MarkSeen(event string)
}

Jump to

Keyboard shortcuts

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