You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 12, 2021. It is now read-only.
I can confirm this behaviour. It doesn't appear that broadcasting to all connected peers is a documented behaviour. It could be if the receiver tracked all received streams, and duplicated messages amongst all peers.
Ok, look, first of all, you should know that Stream interface is a bidirectional link between two nodes, it's not a multichannel.
Also, you should know, that as far as example have only one stream variable instead of global mapping of streams - it will be owerwritten each time you have a new connection. If you want to communicate with multiple devices - you should have a stream mapping (or array) and append any new stream connection to it.
Then, if you want to implement multicast as your own, you should probably map each stream to some 'topic', and when you want to multicast message to every peer in topic list - you should send message to all streams on that topic.
However, instead of creating this mapping and creating multicast mechanism of your own, you can use PubSub mechanism, which has been created for those purposes.
steps :
go run chat.go
in first windowgo run chat.go -d /ip4/127.0.0.1/tcp/64717/p2p/QmefMVVk1tZzfYshYVUFpnwNswtqgXrD6geWo3PFUzQX1Q
in second window.go run chat.go -d /ip4/127.0.0.1/tcp/64717/p2p/QmefMVVk1tZzfYshYVUFpnwNswtqgXrD6geWo3PFUzQX1Q
in third window.Then ,when I type any message such as
Only the second window receive
aaa
the third window receive
bbb
so, how can they receive all messages ?
The text was updated successfully, but these errors were encountered: