Skip to content

Commit

Permalink
Merge pull request #286 from elvizlai/master
Browse files Browse the repository at this point in the history
support: $queue/<topic> for sharing subscribe
  • Loading branch information
Al S-M committed Aug 29, 2019
2 parents 0cff61e + b271d90 commit 2e9e43b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client.go
Expand Up @@ -670,10 +670,14 @@ func (c *client) Subscribe(topic string, qos byte, callback MessageHandler) Toke
sub.Qoss = append(sub.Qoss, qos)
DEBUG.Println(CLI, sub.String())

if strings.HasPrefix(topic, "$share") {
if strings.HasPrefix(topic, "$share/") {
topic = strings.Join(strings.Split(topic, "/")[2:], "/")
}

if strings.HasPrefix(topic, "$queue/") {
topic = strings.TrimPrefix(topic, "$queue/")
}

if callback != nil {
c.msgRouter.addRoute(topic, callback)
}
Expand Down

0 comments on commit 2e9e43b

Please sign in to comment.