Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
66
gaia/apps/system/js/remote/message_controller.js
Executable file
66
gaia/apps/system/js/remote/message_controller.js
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
/* global BaseModule, BroadcastChannel, Service */
|
||||
'use strict';
|
||||
|
||||
(function(exports) {
|
||||
function MessageController() {
|
||||
}
|
||||
|
||||
// An empty EVENTS is necessary for triggering EventMixin in BaseModule.
|
||||
MessageController.EVENTS = [
|
||||
];
|
||||
|
||||
BaseModule.create(MessageController, {
|
||||
DEBUG: false,
|
||||
|
||||
name: 'MessageController',
|
||||
|
||||
postMessage: function(type, detail) {
|
||||
this.debug('[#' + this.displayId + '] ' +
|
||||
'broadcast message to local system: ' + type +
|
||||
', ' + JSON.stringify(detail));
|
||||
|
||||
this.broadcastChannel.postMessage({
|
||||
source: this.displayId,
|
||||
type: type,
|
||||
detail: detail
|
||||
});
|
||||
},
|
||||
|
||||
_start: function() {
|
||||
this.displayId = Service.query('displayId');
|
||||
|
||||
this.broadcastChannel = new BroadcastChannel('multiscreen');
|
||||
this.broadcastChannel.addEventListener('message', this);
|
||||
},
|
||||
|
||||
_stop: function() {
|
||||
this.broadcastChannel.close();
|
||||
this.broadcastChannel = null;
|
||||
},
|
||||
|
||||
_handle_message: function(evt) {
|
||||
var data = evt.data;
|
||||
if (data.target !== this.displayId) {
|
||||
return;
|
||||
}
|
||||
this.debug('[#' + this.displayId + '] ' +
|
||||
'got message from local system: ' + data.type +
|
||||
', ' + JSON.stringify(data.detail));
|
||||
|
||||
switch(data.type) {
|
||||
case 'launch-app':
|
||||
Service.request('launchApp', data.detail).then(() => {
|
||||
this.postMessage('launch-app-success', {
|
||||
config: data.detail
|
||||
});
|
||||
}).catch((reason) => {
|
||||
this.postMessage('launch-app-error', {
|
||||
config: data.detail,
|
||||
reason: reason
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}(window));
|
||||
Loading…
Reference in a new issue