Client for a browser-based content distribution network using WebRTC
var webcdn = new WebCDN();
webcdn.init('ws://webcdn.michelberger.info:1337', function() {
console.log("Your WebCDN is ready!");
});
Currently, we are offering a coordinator server for testing purposes at ws://webcdn.michelberger.info:1337.
$ bower install webcdn
or
$ npm install webcdn-client
Exposed by including webcdn.js
into your project.
Creates a new WebCDN
client:
var webcdn = new WebCDN();
Optionally, the first argument of the WebCDN
constructor can be an options object.
The following options are supported:
bucketUrl
String - Set the root URL for static resource hosting (optional)trackGeolocation
Boolean - Enable the HTML5 Geolocation API (optional)
Connects to a given coordinatorUrl
and fires optionally a callback
function with error
signature (if any).
The client is automatically a peer of the WebCDN network identified with its uuid.
webcdn.init('ws://webcdn.michelberger.info:1337', function() {
console.log("Your WebCDN is ready!");
});
Loads a specific resource identified by a unique contentHash
, explicitly.
webcdn.load('35c22d5973cb21ae0887eda12185747e7a94cd74');
To view the examples, clone the WebCDN repo and install the dependencies:
$ git clone git@github.com:pmichelberger/webcdn-client.git
$ cd webcdn-client
$ npm install
Then run grunt
and visit http://localhost:8000/examples
. Open the same URL via a second browser window and visit your browser network & console panel.
To run the test suite, first install the dependencies, then run grunt
and visit http:localhost:8000/tests
:
$ npm install && bower install
$ grunt