Commit d96d4e4d authored by Hardik Juneja's avatar Hardik Juneja Committed by hardikj

webrtc_gadget: Webrtc gadget which use JIO or Websocket for handshake

parent 4c743377
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>WebRTC Handshake Gadget</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_webrtc_handshake.js"></script>
</head>
<body>
<div data-gadget-url="gadget_jio.html"
data-gadget-scope="jio_gadget"
data-gadget-sandbox="public"></div>
</body>
</html>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_handshake.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>JIO handshaking gadget for Webrtc Gadget</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_handshake_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget to handle handshaking using JIO</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966649.39</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39247.53862.46899</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472631386.92</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*jslint indent:2, maxlen:100, nomen:true*/
/*global rJS, window, WebSocket, RSVP*/
(function (window, rJS, RSVP) {
"use strict";
function createJio(gadget, config) {
return gadget.getDeclaredGadget("jio_gadget")
.push(function (jio_gadget) {
return jio_gadget.createJio(config);
})
.push(null, function(e) {
// TODO: Throw error in a correct way
throw new Error("Wrong Config", config);
})
}
window.promiseDoWhile = function (loopFunction, input) {
// calls loopFunction(input) until it returns a non positive value
// this queue is to protect the inner loop queue from the
// `promiseDoWhile` caller, avoiding it to enqueue the inner
// loop queue.
return new RSVP.Queue()
.push(function () {
// here is the inner loop queue
var loop_queue = new RSVP.Queue();
function iterate(previous_iteration_result) {
if (!previous_iteration_result) {
return input;
}
loop_queue.push(iterate);
return loopFunction(input);
}
return loop_queue
.push(function () {
return loopFunction(input);
})
.push(iterate);
});
};
rJS(window)
.ready(function (g) {
g.props = {};
})
.declareMethod('create_room', function(roomid) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.put(roomid, {});
})
.push(null, function(e){
console.log(e);
})
})
.declareMethod('register', function(roomid, peerid, config) {
var gadget = this;
return new RSVP.Queue()
.push(function() {
return createJio(gadget, config);
})
.push(function() {
return gadget.create_room(roomid);
})
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.putAttachment(roomid, peerid, '');
});
// TODO: create new function, show registered peers?
})
.declareMethod('handle_offer_answer', function (roomid, options) {
var gadget = this,
jio_gadget;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.putAttachment(roomid, options.name, options.data);
})
})
.declareMethod('get_answer', function (roomid, attachment) {
var gadget = this,
jio_gadget;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.getAttachment(roomid, attachment);
});
})
.declareMethod('get_offers', function (roomid) {
var gadget = this,
jio_gadget;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.allAttachments(roomid);
});
})
.declareMethod('wait_until_available', function (roomid, query, callbackPromise) {
// Pool the document until available
var gadget = this,
response,
offers = [];
var action = function(response) {
return gadget.get_offers(roomid)
.push(function(response) {
var offers = [];
for (var doc_name in response) {
if(doc_name.split('_').length === 1 && doc_name === query) {
return gadget.get_answer(roomid, query);
} else if (doc_name.split('_').length === 2
&& doc_name.split('_')[0]+'_' === query) {
offers.push(gadget.get_answer(roomid, doc_name));
}
}
return RSVP.all(offers);
})
.push(function(responses) {
if (responses.constructor !== Array ) {
responses = [responses];
}
if (!responses.length) {
return new RSVP.Queue()
.push(function() {
return RSVP.delay(5000);
})
.push(function() {
return true;
});
}
var blobs = responses;
var texts = [];
for (var blob in blobs) {
texts.push(jIO.util.readBlobAsText(blobs[blob]));
}
return new RSVP.Queue()
.push(function() {
return RSVP.all(texts);
})
.push(function(o){
var a = [];
for (var offer in o) {
a.push(o[offer].target.result);
}
if (typeof callbackPromise === "function") {
return callbackPromise(a);
} else {
offers = a;
return false;
}
});
});
};
return promiseDoWhile(action, callbackPromise);
})
.declareMethod('close', function (roomid, peerid, to) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.removeAttachment(roomid, peerid+"_"+to);
});
});
})(window, rJS, RSVP);
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_handshake.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>JIO handshaking gadget for Webrtc Gadget</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_handshake_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget to handle handshaking using JIO</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966645.61</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.14301.62370.56661</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1475066759.35</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>WebRTC Gadget</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_webrtc.js"></script>
</head>
<body>
</body>
</html>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc Gadget</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>webrtc gadget</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966610.71</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>WebRTC DataChannel Gadget</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_webrtc_jio_bridge.js"></script>
</head>
<body>
<div data-gadget-url="gadget_webrtc_handshake.html"
data-gadget-scope="handshake_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_webrtc_websocket_handshake.html"
data-gadget-scope="websocket_handshake_gadget"
data-gadget-sandbox="public"></div>
<div class="gadget_webrtc"></div>
</body>
</html>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_jio_bridge.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Bridge for Webrtc and JIO Gadgets</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_jio_bridge_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Connector for webrtc and jio gadgets</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966513.56</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.57024.40223.50090</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1473697957.39</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*jslint indent:2, maxlen:100, nomen:true*/
/*global rJS, RSVP, window*/
(function (rJS, window, RSVP) {
"use strict";
var connection_options = [
{
// No need for stun server on the same lan / ipv6
iceServers: [
{'url': 'stun:23.21.150.121'},
{url: 'stun:stun.1.google.com:19302'}
]
},
{
'optional': [{DtlsSrtpKeyAgreement: true}]
}
],
data_channel_options = {reliable: true},
offer_contraints = {
mandatory: {
OfferToReceiveAudio: false,
OfferToReceiveVideo: false
}
};
function declareSubGadget(gadget, url) {
var container_element = gadget.props.element.querySelector("." + url.split(".")[0]),
element = document.createElement("div");
container_element.innerHTML = "";
container_element.appendChild(element);
return gadget.declareGadget(url, {
element: element,
scope: url,
sandbox: "public"
});
}
function dropSubGadget(gadget, scope) {
return gadget.getDeclaredGadget(scope)
.push(function (result) {
return result.getElement();
})
.push(function (element) {
if (element.parentElement) {
element.parentElement.removeChild(element);
}
return gadget.dropGadget(scope);
});
}
function createOffer(gadget, title) {
var webrtc = gadget.props.webrtc_connections["webrtc" + gadget.props.counter];
return webrtc.createConnection.apply(webrtc, connection_options)
.push(function () {
return webrtc.createDataChannel(title, data_channel_options);
})
.push(function () {
return webrtc.createOffer(offer_contraints);
})
.push(function (local_description) {
return webrtc.setLocalDescription(local_description);
})
.push(function () {
return gadget.props.description_defer.promise;
});
}
function registerAnswer (gadget, description) {
return gadget.props.webrtc_connections["webrtc" + gadget.props.counter]
.setRemoteDescription(description)
.push(function () {
return gadget.props.channel_defer.promise;
});
}
function createAnswer(gadget, description) {
var webrtc = gadget.props.webrtc_connections["webrtc" + gadget.props.counter];
return webrtc.createConnection.apply(webrtc, connection_options)
.push(function () {
return webrtc.setRemoteDescription(description);
})
.push(function () {
return webrtc.createAnswer(offer_contraints);
})
.push(function (local_description) {
return webrtc.setLocalDescription(local_description);
})
.push(function () {
return gadget.props.description_defer.promise;
});
}
function waitForConnection (gadget) {
return gadget.props.channel_defer.promise;
}
function handleConnection(gadget, handler_gadget, options, offer) {
// create a new webrtc gadget instance
var new_element = document.createElement("div");
gadget.props.element.querySelector(".gadget_webrtc").appendChild(new_element);
var scope = "webrtc" + gadget.props.counter;
return gadget.declareGadget("gadget_webrtc.html", {
scope: scope,
element: new_element
})
.push(function(webrtc_gadget) {
gadget.props.webrtc_connections[scope] = webrtc_gadget;
if (options.initiator === true) {
return createOffer(gadget, options.peerid)
.push(function (description) {
var params = {'name': options.to+'_'+options.peerid,
'data' : new Blob([JSON.stringify({ from: options.peerid,
action: "offer",
data: description})],
{type : "application/json"})};
return handler_gadget.handle_offer_answer(options.roomid, params);
})
.push(function(){
return handler_gadget.wait_until_available(options.roomid, options.peerid+'_',
function(response){
return registerAnswer(gadget, JSON.parse(response).data)
.push(function () {
return handler_gadget.close(options.roomid,
options.peerid,
options.to,
options.listner);
})
.push(function () {
return false;
});
});
});
} else {
if (!offer.data) {
throw new Error("No offer provided in connect function");
}
return createAnswer(gadget, offer.data)
.push(function (answer) {
var params = {name: options.to+'_'+options.peerid,
data: new Blob([JSON.stringify({ to: options.to,
action: "answer",
data: answer})],
{type : "application/json"}) };
return handler_gadget.handle_offer_answer(options.roomid, params);
})
.push(function () {
return handler_gadget.close(options.roomid, options.peerid, options.to, options.listner);
})
.push(function(){
return RSVP.any([
RSVP.Queue()
.push(function () {
return RSVP.delay(20000);
})
.push(function () {
console.info('-- webrtc client disappears...');
return dropSubGadget(gadget, "webrtc"+gadget.props.counter);
}),
waitForConnection(gadget)
]);
});
}
});
}
rJS(window)
.ready(function (g) {
g.props = {};
g.props.description_defer = RSVP.defer();
g.props.channel_defer = RSVP.defer();
g.props.counter = 0;
g.props.webrtc_connections = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.declareAcquiredMethod("notifyDataChannelMessage", "notifyDataChannelMessage")
.allowPublicAcquisition('notifyDataChannelClosed', function (argument_list, scope) {
var gadget = this;
return dropSubGadget(this, scope)
.push(function () {
return updateInfo(gadget);
});
})
.allowPublicAcquisition("notifyDescriptionCalculated", function (args) {
this.props.description_defer.resolve(args[0]);
this.props.description_defer = RSVP.defer();
})
.allowPublicAcquisition("notifyDataChannelOpened", function () {
this.props.channel_defer.resolve();
})
.declareMethod('send', function (args, to) {
//TODO: Add sent-to by name, functionality here
var webrtc = this.props.webrtc_connections[to];
return webrtc.send.apply(
webrtc,
arguments
);
})
.declareMethod('connect', function(options){
var gadget = this,
jsonOffer,
handler,
roomid = options.roomid,
peerid = options.peerid;
if (options.type === "websocket") {
handler = "websocket_handshake_gadget";
} else if (options.type === "jio") {
handler = "handshake_gadget";
}
gadget.props.handler_gadget = handler;
return this.getDeclaredGadget(handler)
.push(function (handler_gadget){
return handler_gadget.register(options.roomid, options.peerid, options.config);
})
.push(function (){
function connectCallback (offer, handler_gadget) {
return RSVP.Queue()
.push(function(){
if (options.preConnection) {
return options.preConnection(options, offer);
} else {
return;
}
})
.push(function() {
return handleConnection(gadget, handler_gadget, options, offer);
})
.push(function() {
if (options.postConnection) {
return options.postConnection(options, offer);
} else {
return;
}
});
}
if (gadget.props.handler_gadget) {
return gadget.getDeclaredGadget(gadget.props.handler_gadget)
.push(function(handler_gadget) {
if (options.listner) {
return handler_gadget.wait_until_available(roomid, peerid+'_', function(offers){
var connections = [];
// TODO: have a array for channel_defer for concurency?
gadget.props.channel_defer = RSVP.defer();
for (var offer in offers) {
jsonOffer = JSON.parse(offers[offer]);
if (jsonOffer.action === "offer") {
gadget.props.counter += 1;
connections.push(connectCallback(jsonOffer, handler_gadget));
}
}
return RSVP.all(connections);
});
} else {
return handleConnection(gadget, handler_gadget, options);
}
});
} else {
throw new Error("Peer is not registered");
}
});
});
}(rJS, window, RSVP));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_jio_bridge.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Bridge for Webrtc and JIO Gadgets</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_jio_bridge_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Connector for webrtc and jio gadgets (js)</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966500.93</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.14300.3742.31044</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1475066648.69</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Share jIO</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_webrtc_serverless_demo_master_helper.js"></script>
</head>
<body>
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div>
<div class="ui-block-b">
<p data-i18n="This is a renderJS gadget which shares a jIO storage via WebRTC.">This is a renderJS gadget which shares a jIO storage via WebRTC.</p>
<h2 data-i18n="Peer list">Peer list</h2>
<p><span data-i18n="Connected peers:">Connected peers:</span> <span class="peer_count">0</span></p>
<pre class="info"></pre>
</div>
<div class="ui-block-c"></div>
</div>
<div class="gadget_handshake">
<div data-gadget-url="gadget_webrtc_handshake.html" data-gadget-scope="gadget_handshake.html">
</div>
</div>
<div class="gadget_webrtc_jio_bridge"></div>
</body>
</html>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master_helper.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc with JIO demo App</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master_helper_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>share jio with slaves</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472731728.11</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39310.7473.35379</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472635088.36</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*global window, rJS, document, RSVP, console, DOMException */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, document, RSVP, console, DOMException) {
"use strict";
window.promiseDoWhile = function (loopFunction, input) {
// calls loopFunction(input) until it returns a non positive value
// this queue is to protect the inner loop queue from the
// `promiseDoWhile` caller, avoiding it to enqueue the inner
// loop queue.
return new RSVP.Queue()
.push(function () {
// here is the inner loop queue
var loop_queue = new RSVP.Queue();
function iterate(previous_iteration_result) {
if (!previous_iteration_result) {
return input;
}
loop_queue.push(iterate);
return loopFunction(input);
}
return loop_queue
.push(function () {
return loopFunction(input);
})
.push(iterate);
});
};
function dropSubGadget(gadget, scope) {
return gadget.getDeclaredGadget(scope)
.push(function (result) {
return result.getElement();
})
.push(function (element) {
if (element.parentElement) {
element.parentElement.removeChild(element);
}
delete gadget.state_parameter_dict.scope_ip[scope];
return gadget.dropGadget(scope);
});
}
function getWebRTCScopeList(gadget) {
var result_list = [],
element_list = gadget.state_parameter_dict.element.querySelector(".gadget_webrtc_jio_bridge")
.childNodes,
i;
for (i = 0; i < element_list.length; i += 1) {
result_list.push(element_list[i].getAttribute("data-gadget-scope"));
}
return result_list;
}
function updateInfo(gadget) {
var scope_list = getWebRTCScopeList(gadget),
i,
result = "";
for (i = 0; i < scope_list.length; i += 1) {
result += gadget.state_parameter_dict.scope_ip[scope_list[i]] + "\n";
}
gadget.state_parameter_dict.element.querySelector(".info").textContent = result;
gadget.state_parameter_dict.element.querySelector(".peer_count").textContent = i;
}
function sendWebRTC(gadget, rtc_gadget, scope, message) {
return rtc_gadget.send(message)
.push(undefined, function (error) {
if ((error instanceof DOMException) && (error.name === 'InvalidStateError')) {
return dropSubGadget(gadget, scope)
.push(function () {
return updateInfo(gadget);
}, function (error) {
console.log("-- Can not drop remote subgadget " + scope);
console.log(error);
return;
});
}
throw error;
});
}
rJS(window)
.ready(function (gadget) {
// Initialize the gadget local parameters
gadget.state_parameter_dict = {
websocket_initialized: false,
counter: 0,
connecting: false,
scope_ip: {}
};
return gadget.getElement()
.push(function (element) {
gadget.state_parameter_dict.element = element;
})
.push(function () {
return updateInfo(gadget);
});
})
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_repair", "jio_repair")
.allowPublicAcquisition('notifyDataChannelClosed', function (argument_list, scope) {
/*jslint unparam:true*/
var gadget = this;
return dropSubGadget(this, scope)
.push(function () {
return updateInfo(gadget);
});
})
.allowPublicAcquisition("notifyDataChannelMessage", function (argument_list, scope) {
var json = JSON.parse(argument_list[0]),
rtc_gadget,
context = this;
return context.getDeclaredGadget(scope)
.push(function (g) {
rtc_gadget = g;
// Call jio API
return context["jio_" + json.method_name].apply(context, json.argument_list);
})
.push(function (result) {
return sendWebRTC(context, rtc_gadget, scope, JSON.stringify({
id: json.id,
result: result,
type: "jio_response"
}));
}, function (error) {
return sendWebRTC(context, rtc_gadget, scope, JSON.stringify({
id: json.id,
result: error,
type: "error"
}));
});
})
.declareMethod('connect', function(handshake_gadget, room_id, offer) {
var gadget = this,
scope,
rtc_gadget;
return new RSVP.Queue()
.push(function(response) {
gadget.state_parameter_dict.connecting = true;
gadget.state_parameter_dict.counter += 1;
var new_element = document.createElement("div");
gadget.state_parameter_dict.element.querySelector(".gadget_webrtc_jio_bridge").appendChild(new_element);
scope = "webrtc" + gadget.state_parameter_dict.counter;
return gadget.declareGadget("gadget_webrtc_jio_bridge.html", {
scope: scope,
element: new_element
})
.push(function(gg){
rtc_gadget = gg;
// https://github.com/diafygi/webrtc-ips
var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/,
ip_list = [],
ip_dict = {},
ip_addr,
line_list = JSON.parse(offer.data).sdp.split('\n'),
i;
for (i = 0; i < line_list.length; i += 1) {
if (line_list[i].indexOf('a=candidate:') === 0) {
ip_addr = ip_regex.exec(line_list[i])[1];
if (!ip_addr.match(/^[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}$/)) {
// Hide ipv6
if (!ip_dict[ip_addr]) {
ip_list.push(ip_addr);
ip_dict[ip_addr] = true;
}
}
}
}
gadget.state_parameter_dict.scope_ip[scope] = ip_list;
return rtc_gadget.connect({
roomid: room_id,
peerid: 'master',
to: offer.from,
offer: JSON.stringify(offer.data)
});
})
.push(function () {
return RSVP.any([
RSVP.Queue()
.push(function () {
return RSVP.delay(20000);
})
.push(function () {
console.info('-- webrtc client disappears...');
return dropSubGadget(gadget, scope);
}),
rtc_gadget.waitForConnection()
]);
})
.push(function () {
gadget.state_parameter_dict.connecting = false;
return updateInfo(gadget);
});
})
})
.declareMethod('initiate', function (roomid) {
var gadget = this,
handshake_gadget,
rtc_gadget,
blob;
return this.getDeclaredGadget('gadget_handshake.html')
.push(function (gad) {
handshake_gadget = gad;
roomid = "/"+roomid+"/";
return handshake_gadget.create_room(roomid);
})
.push(function () {
return gadget.declareGadget("gadget_webrtc_jio_bridge.html")
})
.push(function (rg) {
// register peer
rtc_gadget = rg;
return rtc_gadget.register(roomid, 'master');
})
.push(function (r) {
var peerid = 'master';
return handshake_gadget.wait_until_available(roomid, peerid+'_', function (offers) {
var connections = [];
for (var offer in offers) {
connections.push(gadget.connect(handshake_gadget, roomid, JSON.parse(offers[offer].target.result)));
}
return RSVP.all(connections);
});
});
});
}(window, rJS, document, RSVP, console, DOMException));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>contributors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master_helper.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc with JIO demo App</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master_helper_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Share jIO Page JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472731710.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39310.18911.56729</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472635108.35</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html manifest="master.appcache">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Serverless WebRTC - Master</title>
<style type="text/css">
body {
background-color: #f9f9f9;
color: #2C3E50;
font-family: Arial;
}
.ui-content, .ui-responsive {
background-color: white;
border: 1px solid #2C3E50;
border-radius: .375em;
padding: 1em;
width: 50%;
margin: 0 auto 1em;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.ui-responsive div p:first-child {
display: none;
}
@media (max-width: 48em) {
.ui-content, .ui-responsive {
width: 100%;
}
}
h2, h3 {
padding: 0;
margin: 0;
font-size: 1.17em;
text-align: center;
}
label {
width: 60%;
display: inline-block;
padding: .5em 0;
}
label span {
display: inline-block;
width: 40%;
padding-right: .5em;
}
</style>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<!-- custom -->
<script src="gadget_webrtc_serverless_demo_master.js" type="text/javascript"></script>
</head>
<body>
<!-- MASTER -->
<!-- NOTE: must have BroadCaster running on same device to work -->
<div class="ui-content">
<h3>Master</h3>
<ul>
<li>The master gadget contains a jIO storage indexedDB.</li>
<li>Slaves connect to master over WebSockets URL set by the Broadcaster</li>
<li>Once webRTC is active the slave can access the storage over webRTC</li>
</div>
<div class="ui-content">
<form class="ops-form-initializer">
<h3> Create a Room </h3>
<br>
<label><span>Name your room</span><input type="text" class="ops-socket-connector" /></label>
<input type="submit" value="Do It" />
</form>
</div>
<!-- socket broadcaster -->
<div data-gadget-url="gadget_webrtc_serverless_demo_master_helper.html"
data-gadget-scope="share_storage_via_webrtc"
data-gadget-sandbox="public"></div>
<!-- storage -->
<div data-gadget-url="gadget_jio.html"
data-gadget-scope="jio_gadget"
data-gadget-sandbox="public"></div>
</body>
</html>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc with JIO demo App</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Master for demo WebRTC application</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39288.14205.2013</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472633817.03</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*global window, rJS, document, RSVP, console, DOMException */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, document, RSVP, console, DOMException) {
"use strict";
/////////////////////////////////////////////////////////////////
// Some functions
/////////////////////////////////////////////////////////////////
function createJio(gadget) {
return gadget.getDeclaredGadget("jio_gadget")
.push(function (jio_gadget) {
return jio_gadget.createJio({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
"type": "indexeddb",
"database": "serverless"
}
}
});
});
}
/////////////////////////////////////////////////////////////////
// Gadget behaviour
/////////////////////////////////////////////////////////////////
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
.ready(function (gadget) {
gadget.state_parameter_dict = {};
return gadget.getElement()
.push(function (element) {
gadget.state_parameter_dict.element = element;
});
})
// Configure jIO to indexeddb
.ready(function (gadget) {
return createJio(gadget);
})
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// published methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_post", function (my_param_list) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (my_gadget) {
return my_gadget.post.apply(my_gadget, my_param_list);
});
})
.allowPublicAcquisition("jio_get", function (my_param_list) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (my_gadget) {
return my_gadget.get.apply(my_gadget, my_param_list);
});
})
.allowPublicAcquisition("jio_allDocs", function (my_param_list) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (my_gadget) {
return my_gadget.allDocs.apply(my_gadget, my_param_list);
});
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// declared services
/////////////////////////////////////////////////////////////////
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function() {
return gadget.getElement()
})
.push(function (element) {
function initializeWebrtcConnecton(my_event) {
var value = element.querySelector(".ops-socket-connector").value;
return gadget.getDeclaredGadget('share_storage_via_webrtc')
.push(function(g){
g.initiate(value);
})
}
// Listen to form submit
return loopEventListener(
element,
'submit',
false,
initializeWebrtcConnecton
);
})
});
}(window, rJS, document, RSVP, console, DOMException));
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc with JIO demo App</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_serverless_demo_master_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Master for demo WebRTC application</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39307.56761.32460</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472634987.37</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Jio Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_webrtc_serverless_demo_slave_helper.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_jio.html"
data-gadget-scope="jio_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_webrtc_handshake.html"
data-gadget-scope="handshake_gadget"
data-gadget-sandbox="public"></div>
<div class="gadget_webrtc_jio_bridge"></div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_serverless_demo_slave_helper.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc with JIO demo App</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_serverless_demo_slave_helper_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>helper for webrtc demo application slave</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966544.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39280.31348.37853</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472633497.48</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*global window, rJS, document, RSVP */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, document, RSVP) {
"use strict";
var timeout = 600000;
function S4() {
return ('0000' + Math.floor(
Math.random() * 0x10000 /* 65536 */
).toString(16)).slice(-4);
}
function UUID() {
return S4() + S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + S4() + S4();
}
function wrapJioAccess(gadget, method_name, argument_list) {
return gadget.getDeclaredGadget('gadget_webrtc_jio_bridge.html')
.push(function (rtc_gadget) {
gadget.state_parameter_dict.message_count += 1;
gadget.state_parameter_dict.message_dict[gadget.state_parameter_dict.message_count] = RSVP.defer();
return RSVP.all([
rtc_gadget.send(JSON.stringify({
id: gadget.state_parameter_dict.message_count,
type: "jio_query",
method_name: method_name,
argument_list: Array.prototype.slice.call(argument_list)
})),
RSVP.any([
RSVP.timeout(timeout),
gadget.state_parameter_dict.message_dict[gadget.state_parameter_dict.message_count].promise
])
]);
})
.push(function (result_list) {
return result_list[1];
});
}
function declareSubGadget(gadget, url) {
var container_element = gadget.state_parameter_dict.element.querySelector("." + url.split(".")[0]),
element = document.createElement("div");
container_element.innerHTML = "";
container_element.appendChild(element);
return gadget.declareGadget(url, {
element: element,
scope: url,
sandbox: "public"
});
}
rJS(window)
.ready(function (gadget) {
// Initialize the gadget local parameters
gadget.state_parameter_dict = {};
return gadget.getElement()
.push(function (element) {
gadget.state_parameter_dict.element = element;
});
})
.allowPublicAcquisition("notifyDataChannelMessage", function (argument_list) {
var json = JSON.parse(argument_list[0]),
context = this;
if (json.type === "jio_response") {
context.state_parameter_dict.message_dict[json.id].resolve(json.result);
} else if (json.type === "error") {
context.state_parameter_dict.message_dict[json.id].reject(json.result);
}
// Drop all other kind of messages
})
.allowPublicAcquisition("notifyWebSocketMessage", function (argument_list) {
var json = JSON.parse(argument_list[0]),
gadget = this;
if (json.action === "answer") {
if (json.to === gadget.state_parameter_dict.uuid) {
gadget.state_parameter_dict.answer_defer.resolve(json.data);
}
}
})
.declareMethod('createJio', function (options) {
var context = this,
roomid = "/"+options.room+"/",
rtc_gadget,
handshake_gadget;
return declareSubGadget(context, 'gadget_webrtc_jio_bridge.html')
.push(function (gadget) {
context.state_parameter_dict.uuid = UUID();
context.state_parameter_dict.message_count = 0;
context.state_parameter_dict.message_dict = {};
rtc_gadget = gadget;
// register peer
return rtc_gadget.register(roomid, context.state_parameter_dict.uuid);
})
.push(function(peers){
var options = { roomid: roomid,
peerid: context.state_parameter_dict.uuid,
initiator: true,
to: 'master' }
return rtc_gadget.connect(options);
})
})
.declareMethod('allDocs', function () {
return wrapJioAccess(this, 'allDocs', arguments);
})
.declareMethod('get', function () {
return wrapJioAccess(this, 'get', arguments);
})
.declareMethod('put', function () {
return wrapJioAccess(this, 'put', arguments);
})
.declareMethod('post', function () {
return wrapJioAccess(this, 'post', arguments);
})
.declareMethod('remove', function () {
return wrapJioAccess(this, 'remove', arguments);
})
}(window, rJS, document, RSVP));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>contributors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_webrtc_serverless_demo_slave_helper.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Webrtc with JIO demo App</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_webrtc_serverless_demo_slave_helper_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>helper for webrtc demo application slave (js)</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1471966535.92</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.39312.52960.8294</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1472635259.04</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html manifest="slave.appcache">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Serverless WebRTC - Slave</title>
<style type="text/css">
body {
background-color: #f9f9f9;
color: #2C3E50;
font-family: Arial;
}
.ui-content, .ui-responsive {
background-color: white;
border: 1px solid #2C3E50;
border-radius: .375em;
padding: 1em;
width: 50%;
margin: 0 auto 1em;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
@media (max-width: 48em) {
.ui-content, .ui-responsive {
width: 100%;
}
}
h2, h3 {
padding: 0;
margin: 0;
font-size: 1.17em;
text-align: center;
}
label {
width: 60%;
display: inline-block;
padding: .5em 0;
}
label span {
display: inline-block;
width: 40%;
padding-right: .5em;
}
</style>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<!-- custom -->
<script src="gadget_webrtc_serverless_demo_slave.js" type="text/javascript"></script>
</head>
<body>
<!-- SLAVE -->
<!-- connect to master via WebSockets, then access master storage via WebRTC -->
<!-- shared storage access -->
<div data-gadget-url="gadget_webrtc_serverless_demo_slave_helper.html"
data-gadget-scope="access_storage_via_webrtc"
data-gadget-sandbox="public"></div>
<div class="ui-content">
<h3 style="display:inline-block;">Status:</h3>
<span class="ops-status"></span>
</div>
<div class="ui-content">
<form class="ops-form-initializer">
<h3>Welcome Minions of WWW!</h3>
<label><span>Name your Master</span><input type="text" class="ops-socket-connector" /></label>
<input type="submit" value="Take me to church" />
</form>
</div>
<div class="ui-content">
<form class="ops-form-create">
<h3>Create Records</h3>
<label><span>First Name</span><input type="text" name="field_first_name" /></label>
<label><span>Last Name</span><input type="text" name="field_last_name" /></label>
<input type="submit" value="Create Record" />
</form>
</div>
<div class="ui-content">
<form class="ops-form-query">
<h3>Query Records</h3>
<label><span>Search</span><input type="search" name="field_search_string" /></label>
<input type="submit" value="Search For Names" />
</form>
<ul class="ops-result-list">
</ul>
</div>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Share jIO</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_webrtc_websocket_handshake.js"></script>
</head>
<body>
<div class="gadget_websocket">
<div data-gadget-url="gadget_websocket.html" data-gadget-scope="gadget_websocket">
</div>
</div>
</body>
</html>
/*jslint indent:2, maxlen:80, nomen:true */
/*global rJS, window, WebSocket, RSVP*/
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
.ready(function (g) {
g.props = {};
g.props.notify_websocket_message = function() {};
})
.allowPublicAcquisition("notifyWebSocketMessage", function (argument_list) {
if ( JSON.parse(argument_list[0]).from !== this.props.peerid) {
return this.props.notify_websocket_message(argument_list);
}
})
.allowPublicAcquisition("notifyWebSocketClosed", function (argument_list) {
return;
})
.declareMethod('create_room', function(roomid) {
this.props.roomid = roomid;
return RSVP.promise;
})
.declareMethod('register', function(roomid, peerid, config) {
var gadget = this;
gadget.props.peerid = peerid;
return gadget.getDeclaredGadget('gadget_websocket')
.push(function (socket_gadget) {
gadget.props.ws_url = config.url;
return socket_gadget.createSocket(config.url);
});
})
.declareMethod('handle_offer_answer', function (roomid, offer) {
var gadget = this;
return new RSVP.Queue()
.push(function() {
return jIO.util.readBlobAsText(offer.data);
})
.push(function (result) {
offer = result.target.result;
return gadget.getDeclaredGadget("gadget_websocket");
})
.push(function (g) {
return g.send(offer);
});
})
.declareMethod('get_answer', function (roomid, attachment) {
var gadget = this;
return;
})
.declareMethod('get_offers', function (roomid) {
var gadget = this;
return;
})
.declareMethod('wait_until_available', function (roomid, query, prom) {
// execute given function on each websocket message
var gadget = this,
response,
offers;
gadget.props.notify_websocket_message = prom;
})
.declareMethod('close', function (roomid, peerid, to, listner) {
if (!listner) {
var gadget = this;
return gadget.getDeclaredGadget("gadget_websocket")
.push(function (socket_gadget) {
return socket_gadget.close();
});
}
});
})(window, rJS, RSVP);
\ No newline at end of file
erp5_web_renderjs_ui
\ No newline at end of file
web_page_module/gadget_webrtc_handshake_html
web_page_module/gadget_webrtc_handshake_js
web_page_module/gadget_webrtc_html
web_page_module/gadget_webrtc_jio_bridge_html
web_page_module/gadget_webrtc_jio_bridge_js
web_page_module/gadget_webrtc_js
web_page_module/gadget_webrtc_serverless_demo_master_helper_html
web_page_module/gadget_webrtc_serverless_demo_master_helper_js
web_page_module/gadget_webrtc_serverless_demo_master_html
web_page_module/gadget_webrtc_serverless_demo_master_js
web_page_module/gadget_webrtc_serverless_demo_slave_helper_html
web_page_module/gadget_webrtc_serverless_demo_slave_helper_js
web_page_module/gadget_webrtc_serverless_demo_slave_html
web_page_module/gadget_webrtc_serverless_demo_slave_js
web_page_module/gadget_webrtc_websocket_handshake_js
web_page_module/gadget_webrtc_websocket_handshake_html
\ No newline at end of file
web_page_module/gadget_webrtc_handshake_html
web_page_module/gadget_webrtc_handshake_js
web_page_module/gadget_webrtc_html
web_page_module/gadget_webrtc_jio_bridge_html
web_page_module/gadget_webrtc_jio_bridge_js
web_page_module/gadget_webrtc_js
web_page_module/gadget_webrtc_serverless_demo_master_helper_html
web_page_module/gadget_webrtc_serverless_demo_master_helper_js
web_page_module/gadget_webrtc_serverless_demo_master_html
web_page_module/gadget_webrtc_serverless_demo_master_js
web_page_module/gadget_webrtc_serverless_demo_slave_helper_html
web_page_module/gadget_webrtc_serverless_demo_slave_helper_js
web_page_module/gadget_webrtc_serverless_demo_slave_html
web_page_module/gadget_webrtc_serverless_demo_slave_js
web_page_module/gadget_webrtc_websocket_handshake_html
web_page_module/gadget_webrtc_websocket_handshake_js
\ No newline at end of file
erp5_webrtc_gadget
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment