github.com/pion/webrtc/v3@v3.2.24/examples/data-channels/README.md (about) 1 # data-channels 2 data-channels is a Pion WebRTC application that shows how you can send/recv DataChannel messages from a web browser 3 4 ## Instructions 5 ### Download data-channels 6 ``` 7 export GO111MODULE=on 8 go get github.com/pion/webrtc/v3/examples/data-channels 9 ``` 10 11 ### Open data-channels example page 12 [jsfiddle.net](https://jsfiddle.net/e41tgovp/) 13 14 ### Run data-channels, with your browsers SessionDescription as stdin 15 In the jsfiddle the top textarea is your browser's session description, press `Copy browser SDP to clipboard` or copy the base64 string manually and: 16 #### Linux/macOS 17 Run `echo $BROWSER_SDP | data-channels` 18 #### Windows 19 1. Paste the SessionDescription into a file. 20 1. Run `data-channels < my_file` 21 22 ### Input data-channels's SessionDescription into your browser 23 Copy the text that `data-channels` just emitted and copy into second text area 24 25 ### Hit 'Start Session' in jsfiddle 26 Under Start Session you should see 'Checking' as it starts connecting. If everything worked you should see `New DataChannel foo 1` 27 28 Now you can put whatever you want in the `Message` textarea, and when you hit `Send Message` it should appear in your terminal! 29 30 Pion WebRTC will send random messages every 5 seconds that will appear in your browser. 31 32 Congrats, you have used Pion WebRTC! Now start building something cool 33 34 ## Architecture 35 36 ```mermaid 37 flowchart TB 38 Browser--Copy Offer from TextArea-->Pion 39 Pion--Copy Text Print to Console-->Browser 40 subgraph Pion[Go Peer] 41 p1[Create PeerConnection] 42 p2[OnConnectionState Handler] 43 p3[Print Connection State] 44 p2-->p3 45 p4[OnDataChannel Handler] 46 p5[OnDataChannel Open] 47 p6[Send Random Message every 5 seconds to DataChannel] 48 p4-->p5-->p6 49 p7[OnDataChannel Message] 50 p8[Log Incoming Message to Console] 51 p4-->p7-->p8 52 p9[Read Session Description from Standard Input] 53 p10[SetRemoteDescription with Session Description from Standard Input] 54 p11[Create Answer] 55 p12[Block until ICE Gathering is Complete] 56 p13[Print Answer with ICE Candidatens included to Standard Output] 57 end 58 subgraph Browser[Browser Peer] 59 b1[Create PeerConnection] 60 b2[Create DataChannel 'foo'] 61 b3[OnDataChannel Message] 62 b4[Log Incoming Message to Console] 63 b3-->b4 64 b5[Create Offer] 65 b6[SetLocalDescription with Offer] 66 b7[Print Offer with ICE Candidates included] 67 68 end 69 ```