Event refactor

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-07-18 10:45:05 -03:00
parent 6eaece99c5
commit 4731d8ec98
17 changed files with 198 additions and 125 deletions

View File

@@ -2,15 +2,24 @@ package event
type EventType string
func (e EventType) String() string {
return string(e)
}
const INSTANCE_VIEWPORT_RESIZE EventType = "instance viewport resize"
const INSTANCE_DELETE EventType = "instance delete"
const INSTANCE_NEW EventType = "instance new"
const INSTANCE_STATS EventType = "instance stats"
const INSTANCE_TERMINAL_OUT EventType = "instance terminal out"
const SESSION_END EventType = "session end"
const SESSION_READY EventType = "session ready"
const SESSION_BUILDER_OUT EventType = "session builder out"
type Handler func(args ...interface{})
type Handler func(sessionId string, args ...interface{})
type AnyHandler func(eventType EventType, sessionId string, args ...interface{})
type EventApi interface {
Emit(name EventType, args ...interface{})
Emit(name EventType, sessionId string, args ...interface{})
On(name EventType, handler Handler)
OnAny(handler AnyHandler)
}