Skip to content

Commit

Permalink
Add DeleteRoutes (public API) to delete callbacks for specific topics…
Browse files Browse the repository at this point in the history
…, related to eclipse#331.

Signed-off-by: Daichi Tomaru <banaoa7543@gmail.com>
  • Loading branch information
tomatod committed Dec 26, 2022
1 parent 4b066a0 commit 5b74826
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client.go
Expand Up @@ -111,6 +111,8 @@ type Client interface {
// a new go routine.
// callback must be safe for concurrent use by multiple goroutines.
AddRoute(topic string, callback MessageHandler)
// DeleteRoutes allow you to delete handlers for messages on specific topics.
DeleteRoutes(topics ...string)
// OptionsReader returns a ClientOptionsReader which is a copy of the clientoptions
// in use by the client.
OptionsReader() ClientOptionsReader
Expand Down Expand Up @@ -186,6 +188,13 @@ func (c *client) AddRoute(topic string, callback MessageHandler) {
}
}

// DeleteRoutes allow you to delete handlers for messages on specific topics.
func (c *client) DeleteRoutes(topics ...string) {
for _, topic := range topics {
c.msgRouter.deleteRoute(topic)
}
}

// IsConnected returns a bool signifying whether
// the client is connected or not.
// connected means that the connection is up now OR it will
Expand Down

0 comments on commit 5b74826

Please sign in to comment.