identify control messages

This commit is contained in:
Marcelo Pires
2018-09-05 15:17:11 +02:00
parent 3586f4d799
commit ffa426bf69
2 changed files with 21 additions and 5 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/thesyncim/faye/transport"
"log"
"strconv"
"strings"
"sync"
"sync/atomic"
)
@ -62,15 +61,21 @@ func (w *Websocket) readWorker() error {
}
//dispatch
msg := payload[0]
if strings.HasPrefix(msg.Channel, "/meta") {
continue //todo update introspect message and update state
if transport.IsControlMsg(msg.Channel) {
//handle it
log.Println("recv control message", debugJson(msg))
continue
}
w.subsMu.Lock()
subscription := w.subs[msg.Channel]
w.subsMu.Unlock()
subscription <- &msg
if subscription != nil {
subscription <- &msg
}
}
}