Page MenuHomePhabricator

D9380.diff
No OneTemporary

D9380.diff

diff --git a/support/aphlict/client/src/Aphlict.as b/support/aphlict/client/src/Aphlict.as
--- a/support/aphlict/client/src/Aphlict.as
+++ b/support/aphlict/client/src/Aphlict.as
@@ -31,6 +31,10 @@
ExternalInterface.call('JX.Aphlict.didReceiveEvent', type, object);
}
+ protected function error(error:Error):void {
+ this.externalInvoke('error', error.toString());
+ }
+
protected function log(message:String):void {
this.externalInvoke('log', message);
}
diff --git a/support/aphlict/client/src/AphlictMaster.as b/support/aphlict/client/src/AphlictMaster.as
--- a/support/aphlict/client/src/AphlictMaster.as
+++ b/support/aphlict/client/src/AphlictMaster.as
@@ -131,34 +131,38 @@
}
private function didReceiveSocket(event:Event):void {
- var b:ByteArray = this.readBuffer;
- this.socket.readBytes(b, b.length);
+ try {
+ var b:ByteArray = this.readBuffer;
+ this.socket.readBytes(b, b.length);
- do {
- b = this.readBuffer;
- b.position = 0;
+ do {
+ b = this.readBuffer;
+ b.position = 0;
- if (b.length <= 8) {
- break;
- }
+ if (b.length <= 8) {
+ break;
+ }
- var msg_len:Number = parseInt(b.readUTFBytes(8), 10);
- if (b.length >= msg_len + 8) {
- var bytes:String = b.readUTFBytes(msg_len);
- var data:Object = vegas.strings.JSON.deserialize(bytes);
- var t:ByteArray = new ByteArray();
- t.writeBytes(b, msg_len + 8);
- this.readBuffer = t;
-
- // Send the message to all clients.
- for (var client:String in this.clients) {
- this.log('Sending message to client: ' + client);
- this.send.send(client, 'receiveMessage', data);
+ var msg_len:Number = parseInt(b.readUTFBytes(8), 10);
+ if (b.length >= msg_len + 8) {
+ var bytes:String = b.readUTFBytes(msg_len);
+ var data:Object = vegas.strings.JSON.deserialize(bytes);
+ var t:ByteArray = new ByteArray();
+ t.writeBytes(b, msg_len + 8);
+ this.readBuffer = t;
+
+ // Send the message to all clients.
+ for (var client:String in this.clients) {
+ this.log('Sending message to client: ' + client);
+ this.send.send(client, 'receiveMessage', data);
+ }
+ } else {
+ break;
}
- } else {
- break;
- }
- } while (true);
+ } while (true);
+ } catch (err:Error) {
+ this.error(err);
+ }
}
}
diff --git a/webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js b/webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
--- a/webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
+++ b/webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
@@ -24,25 +24,39 @@
// Respond to a notification from the Aphlict notification server. We send
// a request to Phabricator to get notification details.
function onaphlictmessage(type, message) {
- if (type == 'receive') {
- var routable = new JX.Request('/notification/individual/', onnotification)
- .addData({key: message.key})
- .getRoutable();
+ switch (type) {
+ case 'error':
+ new JX.Notification()
+ .setContent('(Aphlict) ' + message)
+ .alterClassName('jx-notification-error', true)
+ .show();
+ break;
- routable
- .setType('notification')
- .setPriority(250);
+ case 'receive':
+ var routable = new JX.Request(
+ '/notification/individual/',
+ onnotification);
- JX.Router.getInstance().queue(routable);
- } else if (__DEV__) {
- if (config.debug) {
- var details = message ? JX.JSON.stringify(message) : '';
+ routable
+ .addData({key: message.key})
+ .getRoutable();
- new JX.Notification()
- .setContent('(Aphlict) [' + type + '] ' + details)
- .alterClassName('jx-notification-debug', true)
- .show();
- }
+ routable
+ .setType('notification')
+ .setPriority(250);
+
+ JX.Router.getInstance().queue(routable);
+ break;
+
+ default:
+ if (__DEV__ && config.debug) {
+ var details = message ? JX.JSON.stringify(message) : '';
+
+ new JX.Notification()
+ .setContent('(Aphlict) [' + type + '] ' + details)
+ .alterClassName('jx-notification-debug', true)
+ .show();
+ }
}
}
@@ -63,8 +77,7 @@
// If the notification affected an object on this page, show a
// permanent reload notification if we aren't already.
- if ((response.primaryObjectPHID in config.pageObjects) &&
- !showing_reload) {
+ if ((response.primaryObjectPHID in config.pageObjects) && !showing_reload) {
var reload = new JX.Notification()
.setContent('Page updated, click to reload.')
.alterClassName('jx-notification-alert', true)
diff --git a/webroot/rsrc/swf/aphlict.swf b/webroot/rsrc/swf/aphlict.swf
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001

File Metadata

Mime Type
text/plain
Expires
Wed, May 22, 12:32 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6275517
Default Alt Text
D9380.diff (5 KB)

Event Timeline