Skip to content

Commit

Permalink
Merge pull request #25 from noflo/opener_protocol
Browse files Browse the repository at this point in the history
Switch from iframe+webrtc to postmessage runtime
  • Loading branch information
jonnor committed Aug 11, 2017
2 parents b694bb7 + 8a8f257 commit 83d9573
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion spec/fixtures/graphs/Clock.json
@@ -1,7 +1,7 @@
{
"properties": {
"environment": {
"runtime": "noflo-browser",
"type": "noflo-browser",
"content": "<div class='area' title='.area'>\n <img id='clock' src='https://i.imgur.com/0S7R8OU.png' style='position:absolute; width:300px; height:300px; top:0; left:0;' />\n <img id='hours' src='https://i.imgur.com/Fw8L3L1.png' style='position:absolute; top:50px; left:130px; height:200px;' />\n <img id='minutes' src='https://i.imgur.com/WtSz99Q.png' style='position:absolute; top:0; left:140px; height:300px;' />\n <img id='seconds' src='https://i.imgur.com/m2PQs6E.png' style='position:absolute; top:0; left:145px; height:300px;' />\n</div>",
"width": 300,
"height": 300,
Expand Down
3 changes: 1 addition & 2 deletions spec/fixtures/package.json
Expand Up @@ -21,8 +21,7 @@
"noflo-css": "^0.0.2"
},
"devDependencies": {
"noflo-runtime-iframe": "^0.8.0",
"noflo-runtime-webrtc": "^0.8.0"
"noflo-runtime-postmessage": "^0.8.0"
},
"keywords": [
"noflo"
Expand Down
7 changes: 2 additions & 5 deletions tasks/noflo_browser.js
Expand Up @@ -72,11 +72,8 @@ module.exports = function(grunt) {
signalserver: 'https://api.flowhub.io'
});

if (options.debug && !options.exposed_modules['noflo-runtime-webrtc']) {
options.exposed_modules['noflo-runtime-webrtc'] = 'noflo-runtime-webrtc';
}
if (options.debug && !options.exposed_modules['noflo-runtime-iframe']) {
options.exposed_modules['noflo-runtime-iframe'] = 'noflo-runtime-iframe';
if (options.debug && !options.exposed_modules['noflo-runtime-postmessage']) {
options.exposed_modules['noflo-runtime-postmessage'] = 'noflo-runtime-postmessage';
}

// Force task to async mode
Expand Down
23 changes: 6 additions & 17 deletions templates/graphDebug.html
Expand Up @@ -4,7 +4,6 @@
<meta charset="utf-8">
<title><%= name %></title><% _.forEach(scripts, function (path) { %>
<script src="<%= path %>"></script><% }); %>
<script src="https://app.flowhub.io/node_modules/rtc/dist/rtc.js"></script>
<script src="<%= noflo %>"></script>
<style>
#flowhub_debug_url.nodebug {
Expand Down Expand Up @@ -53,7 +52,6 @@
var graph = instance.network.graph;

var queryProtocol = getParameterByName('fbp_protocol');
var queryAddress = getParameterByName('fbp_address');
var queryNoLoad = getParameterByName('fbp_noload');

var runtimeOptions = {
Expand All @@ -71,29 +69,20 @@
runtimeOptions.defaultGraph = graph;
};
if (!queryProtocol) {
queryProtocol = 'webrtc';
queryProtocol = 'opener';
}

var rt = null;
if (queryProtocol == 'webrtc') {
var webrtcRuntime = require('noflo-runtime-webrtc');
if (queryAddress) {
// ID to use specified from outside, normally by Flowhub IDE
rt = webrtcRuntime(queryAddress, runtimeOptions, true);
} else {
// Generate new ID
rt = webrtcRuntime(null, runtimeOptions, true);
rt.signaller = '<%= signalServer %>';
}
var postMessageRuntime = require('noflo-runtime-postmessage');
if (queryProtocol == 'opener') {
var ide = '<%= ideUrl %>';
var debugUrl = ide+'#runtime/endpoint?'+encodeURIComponent('protocol=webrtc&address='+rt.signaller+'#'+rt.id);
var debugUrl = ide+'#runtime/endpoint?'+encodeURIComponent('protocol=opener&address='+window.location.href);
var debugButton = document.getElementById('flowhub_debug_url');
console.log('Debug URL', debugUrl);
debugButton.className = "debug";
debugButton.href = debugUrl;
rt = postMessageRuntime.opener(runtimeOptions, debugButton);
} else if (queryProtocol == 'iframe') {
var iframeRuntime = require('noflo-runtime-iframe');
rt = iframeRuntime(runtimeOptions);
rt = postMessageRuntime.iframe(runtimeOptions);
}

if (rt) {
Expand Down

0 comments on commit 83d9573

Please sign in to comment.