The intent is for this to become a Community Wiki post that is kept up-to-date so developers interested in implementing communication of JSON messages browser-to-browser (p2p) with WebRTC DataChannels have simple yet functional examples.
WebRTC DataChannels are experimental and still in draft. It seems that currently the web is a minefield of outdated WebRTC examples and even more so if a developer is trying to learn the RTCDataChannel API.
Simple yet functional 1-page examples that work today across WebRTC compliant browsers seem very difficult to find. For example, some examples leave out a signaling implementation, others only work for a single browser (e.g. Chrome-Chrome), many are outdated due to recent API changes, and others are so complex they create a barrier to getting started.
Please post examples that meet the following criteria (if something is not met please specify):
- Client-side code is 1-page (200 lines or less)
- Server-side code is 1-page and technology is referenced (e.g. node.js, php, python, etc.)
- Signaling mechanism is implemented and protocol technology is referenced (e.g. WebSockets, long polling, GCM, etc.)
- Working code that runs cross-browser (Chrome, Firefox, Opera, and/or Bowser)
- Minimal options, error handling, abstraction, etc. -- the intent is an elementary example
Here is a working example that uses HTML5 WebSockets for signaling and a node.js backend
signaling technology:
WebSockets
client:
pure html/javascript
server:
node.js
,ws
last tested on:
Firefox 40.0.2
,Chrome 44.0.2403.157 m
,Opera 31.0.1889.174
client-side code:
server-side code: