Web browser polyfill that implement the WebRTC DataChannel API over a websocket. It implement the full latest DataChannel API specification defined at 2013-01-16.
Jesús Leganés Combarro "Piranna" [email protected]
This code can be found at https://github.com/piranna/DataChannel-polyfill
The polyfill is splitted in two parts, the polyfill 'per se' at datachannel.js and the server backend at server-datachannel.js (it needs Node.js, obviusly). To use it it's a matter of three steps:
-
include the datachannel.js file on a script tag on the head section of yout HTML code and call to DCPF_install() function giving the backend server URL as parameter
-
run the backend server
-
there's no third step! :-)
There's also two (public) SSL enabled backend servers that you can use at wss://datachannel-polyfill.nodejitsu.com and wss://datachannel-piranna.dotcloud.com. Just for testing purposes please, the bandwidth is high, but not infinite... :-)
On the 'test' folder you can find a little P2P chat that can be used for testing or just learn how to use the DataChannel API. To run it
-
add a copy of datachannel.js file on the 'test' folder (a symbolic link is enought)
-
run the test server
-
run the backend server (by default is using the one at Nodejitsu)
-
open several browsers pointing to http://localhost:8000 to start chatting :-)
Don't worry about the dotcloud.yml and supervisord.conf files, they are specific for the dotCloud backend server.
-
a web browser with the PeerConnection object (currently Chrome/Chromium >= 19)
-
a Node.js server with the 'ws' module installed for the backend server
-
Use native implementations if both ends support them (currently it requires at least one of the ends doesn't support native DataChannels so it can use the polyfill).
-
Detect and allow the coexistence of native and polyfill implementations on the same network (use polyfill if one of the two ends doesn't support native DataChannels)