Add the OnUnsubscribed hook to the unsubscribeClient method (#122)

Add the OnUnsubscribed hook to the unsubscribeClient method,and change the unsubscribeClient to externally visible. In a clustered environment, if a client is disconnected and then connected to another node, the subscriptions on the previous node need to be cleared.
This commit is contained in:
Wind
2022-12-17 02:23:58 +08:00
committed by GitHub
parent 8d4cc091b4
commit a556feb325
2 changed files with 12 additions and 6 deletions

View File

@@ -844,7 +844,7 @@ func TestServerUnsubscribeClient(t *testing.T) {
s.Topics.Subscribe(cl.ID, pk)
subs := s.Topics.Subscribers("a/b/c")
require.Equal(t, 1, len(subs.Subscriptions))
s.unsubscribeClient(cl)
s.UnsubscribeClient(cl)
subs = s.Topics.Subscribers("a/b/c")
require.Equal(t, 0, len(subs.Subscriptions))
}