From eb57afb1c459024fa1f1a38f38126ec054b98899 Mon Sep 17 00:00:00 2001 From: backkem Date: Thu, 14 Feb 2019 17:38:58 +0100 Subject: [PATCH] Examples: Add readme Relates to #5 --- examples/README.md | 69 ++++++++++++++++++++++++++ {integration => examples}/index.js | 0 {integration => examples}/main.go | 0 {integration => examples}/package.json | 0 4 files changed, 69 insertions(+) create mode 100644 examples/README.md rename {integration => examples}/index.js (100%) rename {integration => examples}/main.go (100%) rename {integration => examples}/package.json (100%) diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..61d0332 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,69 @@ +examples +=== + +## Go +This folder contains an example go app that connects using go-libp2p-webrtc-direct. It can be used as follows: + +### Install dependencies +**TODO**: Check the root readme + +### Listener +```sh +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 +```sh +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 +```sh +npm install +``` + +### Listener +```sh +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 +```sh +node index.js +``` +*Output* +``` +[dialer] Opened connection +[dialer] Opened stream +``` \ No newline at end of file diff --git a/integration/index.js b/examples/index.js similarity index 100% rename from integration/index.js rename to examples/index.js diff --git a/integration/main.go b/examples/main.go similarity index 100% rename from integration/main.go rename to examples/main.go diff --git a/integration/package.json b/examples/package.json similarity index 100% rename from integration/package.json rename to examples/package.json