Simplify Service/Reactor pattern

This commit is contained in:
Jae Kwon
2015-07-21 18:31:01 -07:00
parent 7441e322d0
commit e7c1febb65
14 changed files with 67 additions and 56 deletions

View File

@ -241,14 +241,16 @@ func NewWSConnection(wsConn *websocket.Conn) *WSConnection {
return con
}
func (con *WSConnection) AfterStart() {
func (con *WSConnection) OnStart() {
con.QuitService.OnStart()
// read subscriptions/unsubscriptions to events
go con.read()
// write responses
con.write()
}
func (con *WSConnection) AfterStop() {
func (con *WSConnection) OnStop() {
con.QuitService.OnStop()
con.evsw.RemoveListener(con.id)
// the write loop closes the websocket connection
// when it exits its loop, and the read loop