Add c.isMqtt() and c.isWebsocket()

This hides the check on "c.mqtt != nil" or "c.ws != nil".
Added some tests.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2020-12-02 15:52:06 -07:00
parent 41fac39f8e
commit 67425d23c8
9 changed files with 96 additions and 37 deletions

View File

@@ -132,7 +132,7 @@ const (
func (c *client) parse(buf []byte) error {
// Branch out to mqtt clients. c.mqtt is immutable, but should it become
// an issue (say data race detection), we could branch outside in readLoop
if c.mqtt != nil {
if c.isMqtt() {
return c.mqttParse(buf)
}
var i int