go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

Support multiple peers for the "chat-with-mdns" example

Open MqllR opened this issue 1 year ago • 3 comments

The chat-with-mdns example is pretty limited and quite confusing regarding the streams management. As a libp2p beginner, it is not easy to really get the behavior of the StreamHandler and when another stream is opened.

In addition, the input read from Stdin cannot be consumed from the different goroutines which make the example incompatible with a multi peers setup.

In this PR, I propose to store the peers in a distinct struct to later be able to broadcast messages to all the peers part of the p2p network.

Execution example:

image

MqllR avatar Oct 02 '24 15:10 MqllR

Can you also update the example to use the latest version of go-libp2p? Update the examples/go.mod file to use go-libp2p v0.37.

MarcoPolo avatar Oct 23 '24 16:10 MarcoPolo

@MqllR can you fix the merge conflict and the go check error:

  Error: ./relay/main.go:153:35: network.WithUseTransient is deprecated: Use WithAllowLimitedConn instead.  (SA1019)

p-shahi avatar Dec 02 '24 23:12 p-shahi

Merged master which fix the static check (see https://github.com/libp2p/go-libp2p/pull/3023).

MqllR avatar Dec 03 '24 14:12 MqllR

Automatically closing old open PRs. If you're still interested in merging this please open the PR again and rebase from the latest master, otherwise do nothing.

MarcoPolo avatar Sep 19 '25 21:09 MarcoPolo