Closed D4ryl00 closed 1 year ago
The actual behavior is :
topic, _ := pubsub.Join(address)
, it receives a PeerJoin
event.sub, _ := topic.Subscribe()
, other peers receive the PeerJoin
event.sub.Cancel()
, everyone receive the PeerLeave
event.So to answer my question, we have to subscribe and cancel this subscription to receive the PeerLeave
event. topic.Close()
doesn't emit any event.
what was the resolution?
oh yes, of course. Thanks for the write up.
Is it normal that when a peer closes a topic in a pubsub (with
topic.Close()
), the other peers on the same topic do not receive a PeerLeave event from the EventHandler of that topic? The problem is that when the peer joins the same topic after closing, the other peers do not receive a PeerJoin event. Thus, we cannot handle an action when this peer listens to the topic again.On the other hand, if the peer closes connections with other peers, the peers receive the PeerLeave event. But in my case, I want to keep the connections because a peer can have more than one topic.
I wrote a snippet: https://gist.github.com/D4ryl00/ce34ff1289131b742ec4371f220269ba