npm install
npm run build
npm start
npm test
Peer starting collaboration has to generate a uuid using
var grtcID = GRTC.uuid(); // static function
After that pass that to GRTC module
window.history.pushState('', '', '#' + grtcID); // optional to add to url so can share with others.
var grtc = new GRTC(grtcID, window.location.origin, true); // 3rd param is transport layer for encrypted session.
Peer not starting collaboration has to join and get that grtcID somehow possibly by sharing url
Events
grtc.on('peerFound', function(peer){
// peer => peer signal used for connection establishment
});
grtc.on('peerSignal', function(signal){
// signal => signal that is received from another peer.
});
grtc.on('peerConnected', function(){
// peer is connected.
});
grtc.on('peerData', function(data){
//data is always json stringified
});
Miscellaneous Events
grtc.on('publicKey', function(pubKey){
//pubKey => encrypt shared token using this and send that to peer.
});
grtc.on('peerSecret', function(secret){
//secret => its decrypted using your private key.
});
grtc.on('secretAck', function(){
});
grtc.on('transport', function(){
// you can call grtc.secureSend('something') function
});
Payload should always be JSON object which can be sent directly using grtc.send without stringify