go-libp2p-webrtc-direct/examples/standalone
web3-bot 41a3151f0a
sync: update CI config files (#51)
* bump go.mod to Go 1.17 and run go fix

* bump go.mod to Go 1.17 and run go fix

* bump go.mod to Go 1.17 and run go fix

* bump go.mod to Go 1.17 and run go fix

* add version.json file

* update .github/workflows/automerge.yml

* update .github/workflows/go-test.yml

* update .github/workflows/go-check.yml

Co-authored-by: web3-bot <web3-bot@users.noreply.github.com>
2022-04-06 12:57:18 +02:00
..
README.md Add libp2p example 2019-02-25 22:08:06 +01:00
go.mod sync: update CI config files (#51) 2022-04-06 12:57:18 +02:00
go.sum sync: update CI config files (#47) 2021-11-19 15:19:01 +01:00
index.js Add libp2p example 2019-02-25 22:08:06 +01:00
main.go upgrading dependencies to pass build, commpatible with go-libp2p v0.13.0 and webrtc/v3 v3.0.16 2021-03-21 14:31:43 +01:00
package.json Add libp2p example 2019-02-25 22:08:06 +01:00

README.md

standalone

This example shows the transport being used on its own. It also shows off compatibility with js-libp2p-webrtc-direct.

Go

Install dependencies

TODO: Check the root readme

Listener

go run main.go -listen

Output

[listener] Listening
[listener] Got connection
[listener] Got stream
[listener] Received:
hey, how is it going. I am the dialer
Failed to accept data channel: The association is closed

The last line is harmless warning printed by the pions/webrtc library.

Dialer

go run main.go

Output

Warning: Certificate not checked
[dialer] Opened connection
[dialer] Opened stream
Failed to push SCTP packet: Failed sending reply: dtls: conn is closed
Warning: mux: no endpoint for packet starting with 23
Failed to push SCTP packet: Failed sending reply: dtls: conn is closed
Warning: mux: no endpoint for packet starting with 21
Failed to accept data channel: The association is closed

The warnings printed by the pions/webrtc library are harmless.

Javascript

The equivalent javascript example is also provided. It can be used as follows:

Install dependencies

npm install

Listener

node index.js --listen

Output

[listener] Listening
[listener] Got connection
[listener] Got stream
[listener] Received:
hey, how is it going. I am the dialer

Dialer

node index.js

Output

[dialer] Opened connection
[dialer] Opened stream