diff --git a/relay/wshandlers.go b/relay/wshandlers.go index 6f43aa5..662f69a 100644 --- a/relay/wshandlers.go +++ b/relay/wshandlers.go @@ -144,17 +144,15 @@ func (ws *WsServer) handleClientDisconnect(client *client) { channelsToClear = append(channelsToClear, messageChanKey(topic)) } } - - if client.role == Dapp { - // clear dapp notify channels - publishedChannels := []string{} - for topic := range client.pubTopics.Get() { - ws.publishers.Unset(topic, client) - if ws.publishers.Len(topic) == 0 { - publishedChannels = append(publishedChannels, dappNotifyChanKey(topic)) + for topic := range client.pubTopics.Get() { + ws.publishers.Unset(topic, client) + if ws.publishers.Len(topic) == 0 { + channelsToClear = append(channelsToClear, messageChanKey(topic)) + // for dapp, need to further clear notify channels + if client.role == Dapp { + channelsToClear = append(channelsToClear, dappNotifyChanKey(topic)) } } - channelsToClear = append(channelsToClear, publishedChannels...) } if len(channelsToClear) > 0 { diff --git a/relay/wsserver.go b/relay/wsserver.go index e1ffcae..f499f20 100644 --- a/relay/wsserver.go +++ b/relay/wsserver.go @@ -72,7 +72,7 @@ func (ws *WsServer) NewClientConn(w http.ResponseWriter, r *http.Request) { ws: ws, pubTopics: NewTopicSet(), subTopics: NewTopicSet(), - sendbuf: make(chan SocketMessage, 256), + sendbuf: make(chan SocketMessage, 8), quit: make(chan struct{}), }