Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
Show All 35 Lines | routable | ||||
.setPriority(250); | .setPriority(250); | ||||
JX.Router.getInstance().queue(routable); | JX.Router.getInstance().queue(routable); | ||||
}); | }); | ||||
// Respond to a notification from the Aphlict notification server. We send | // Respond to a notification from the Aphlict notification server. We send | ||||
// a request to Phabricator to get notification details. | // a request to Phabricator to get notification details. | ||||
function onaphlictmessage(type, message) { | function onaphlictmessage(message) { | ||||
switch (type) { | |||||
case 'receive': | |||||
JX.Stratcom.invoke('aphlict-receive-message', null, message); | JX.Stratcom.invoke('aphlict-receive-message', null, message); | ||||
break; | |||||
default: | |||||
case 'error': | |||||
case 'log': | |||||
case 'status': | |||||
if (config.debug) { | |||||
var details = message ? JX.JSON.stringify(message) : ''; | |||||
JX.log('(Aphlict) [' + type + '] ' + details); | |||||
} | |||||
break; | |||||
} | |||||
} | } | ||||
// Respond to a response from Phabricator about a specific notification. | // Respond to a response from Phabricator about a specific notification. | ||||
function onnotification(response) { | function onnotification(response) { | ||||
if (!response.pertinent) { | if (!response.pertinent) { | ||||
return; | return; | ||||
} | } | ||||
Show All 16 Lines | if ((response.primaryObjectPHID in config.pageObjects) && !showing_reload) { | ||||
reload.listen('activate', function() { JX.$U().go(); }); | reload.listen('activate', function() { JX.$U().go(); }); | ||||
reload.show(); | reload.show(); | ||||
showing_reload = true; | showing_reload = true; | ||||
} | } | ||||
} | } | ||||
var client = new JX.Aphlict( | var client = new JX.Aphlict( | ||||
config.id, | config.websocketURI, | ||||
config.server, | |||||
config.port, | |||||
config.subscriptions); | config.subscriptions); | ||||
client | client | ||||
.setHandler(onaphlictmessage) | .setHandler(onaphlictmessage) | ||||
.start(JX.$(config.containerID), config.swfURI); | .start(); | ||||
}); | }); |