Skip to content

Commit

Permalink
fix: already subscribe to topic
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinfeng96 committed Sep 14, 2023
1 parent 33968f0 commit 6fbdacc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions conn/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ func DialChannelWithClient(endpoint string, config *tls.Config, groupID int) (*C
if err = ch.handshakeChannel(); err != nil {
logrus.Errorf("handshake channel protocol failed, use default protocol version")
}
// ch.topicHandlers[blockNotifyPrefix+strconv.Itoa(groupID)] = nil
// if err = ch.sendSubscribedTopics(); err != nil {
// return nil, fmt.Errorf("subscriber block nofity failed")
// }
ch.topicHandlers[blockNotifyPrefix+strconv.Itoa(groupID)] = nil
if err = ch.sendSubscribedTopics(); err != nil {
return nil, fmt.Errorf("subscriber block nofity failed")
}
return ch, nil
})
}
Expand Down Expand Up @@ -752,7 +752,7 @@ func (hc *channelSession) subscribeTopic(topic string, handler func([]byte, *[]b
if handler == nil {
return errors.New("handler is nil")
}
if _, ok := hc.topicHandlers[topic]; ok {
if oldHandler, ok := hc.topicHandlers[topic]; ok && oldHandler != nil {
return errors.New("already subscribed to topic " + topic)
}
hc.topicMu.Lock()
Expand Down

0 comments on commit 6fbdacc

Please sign in to comment.