Skip to content

Commit

Permalink
fix: call onMessage if topic doesn't have handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mehditeymorian committed May 30, 2022
1 parent 0f9824f commit adc98dc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ func (c *Client) AcceptEvents(reader *bufio.Reader) {
c.OnError(err.Code, err.Data)
default:
topics := FindRelatedWildcardTopics(event.Topic, c.Topics)
log.Printf("topics %+v\n", topics)
if len(topics) > 0 {
for _, topic := range topics {
eventHandler, ok := c.OnEvent[topic]
if ok {
eventHandler(event.Data)
} else {
c.OnMessage(topic, event.Data)
}
}
} else {
Expand Down

0 comments on commit adc98dc

Please sign in to comment.