Skip to content

Commit

Permalink
Fix onMessage default msg handler condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Florimond committed Mar 13, 2019
1 parent 6dc4f08 commit 0bd5959
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions v2/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func (c *Client) OnError(handler ErrorHandler) {

// onMessage occurs when MQTT client receives a message
func (c *Client) onMessage(_ mqtt.Client, m mqtt.Message) {
if c.message != nil && !strings.HasPrefix(m.Topic(), "emitter/") {
if !strings.HasPrefix(m.Topic(), "emitter/") {
handlers := c.handlers.Lookup(m.Topic())
if len(handlers) == 0 { // Invoke the default message handler
if len(handlers) == 0 && c.message != nil { // Invoke the default message handler
c.message(c, m)
}

Expand Down

0 comments on commit 0bd5959

Please sign in to comment.