Skip to content

Commit

Permalink
Added somewhat of a RPC/launch args
Browse files Browse the repository at this point in the history
  • Loading branch information
jorys-paulin committed Jul 24, 2018
1 parent a12dcdc commit bfaaafc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"scripts": ["static/js/jquery-2.2.0.min.js", "static/js/material.min.js", "static/js/common.js", "static/js/background.js"]
}
},
"externally_connectable": {
"matches": ["*://localhost:*/*", "*://moonlight-stream.com:*/*", "*://moonlight-stream.github.io:*/*"]
},
"sockets": {
"udp": { "bind": "*", "send": "*" }
},
Expand Down
20 changes: 18 additions & 2 deletions static/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function createWindow(state) {
});
}

chrome.app.runtime.onLaunched.addListener(function() {
console.log('Chrome app runtime launched.');
function launchApp() {
var windowState = 'normal';

if (chrome.storage) {
Expand All @@ -32,4 +31,21 @@ chrome.app.runtime.onLaunched.addListener(function() {
} else {
createWindow(windowState);
}
}

chrome.app.runtime.onLaunched.addListener(function() {
console.log('Chrome app runtime launched.');
launchApp()
});

chrome.runtime.onMessageExternal.addListener(function(request, sender, sendResponse) {
if(request && request.message) {
if(request.message == 'VERSION') {
var manifestData = chrome.runtime.getManifest();
sendResponse({name: 'moonlight-chrome', version: manifestData.version})
}
if(request.message == 'LAUNCH') {
launchApp()
}
}
})

0 comments on commit bfaaafc

Please sign in to comment.