Files
play-with-docker/event/event.go
Jonathan Leibiusky (@xetorthio) 1b0d363ffe Add session keep alive. If client doesn't send a keep alive, after a
specified amount of time the scheduler closes the session
2017-10-16 18:11:15 +02:00

29 lines
912 B
Go

package event
type EventType string
func (e EventType) String() string {
return string(e)
}
var (
INSTANCE_VIEWPORT_RESIZE = EventType("instance viewport resize")
INSTANCE_DELETE = EventType("instance delete")
INSTANCE_NEW = EventType("instance new")
INSTANCE_STATS = EventType("instance stats")
SESSION_NEW = EventType("session new")
SESSION_END = EventType("session end")
SESSION_READY = EventType("session ready")
SESSION_BUILDER_OUT = EventType("session builder out")
SESSION_KEEP_ALIVE = EventType("session keep alive")
)
type Handler func(sessionId string, args ...interface{})
type AnyHandler func(eventType EventType, sessionId string, args ...interface{})
type EventApi interface {
Emit(name EventType, sessionId string, args ...interface{})
On(name EventType, handler Handler)
OnAny(handler AnyHandler)
}