Skip to content

Commit

Permalink
clear topic when no client relates with it (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
windycrypto authored Dec 5, 2023
1 parent 22e0da3 commit 0d8ecc2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions relay/wshandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ func (ws *WsServer) handleClientDisconnect(client *client) {
for topic := range subscribedTopics {
ws.subscribers.Unset(topic, client)
if ws.subscribers.Len(topic) == 0 {
ws.subscribers.Clear(topic)
channelsToClear = append(channelsToClear, messageChanKey(topic))
}
}
for topic := range client.pubTopics.Get() {
ws.publishers.Unset(topic, client)
if ws.publishers.Len(topic) == 0 {
ws.publishers.Clear(topic)
channelsToClear = append(channelsToClear, messageChanKey(topic))
// for dapp, need to further clear notify channels
if client.role == Dapp {
Expand Down

0 comments on commit 0d8ecc2

Please sign in to comment.