Skip to content

Commit

Permalink
Load protobufs asynchronously. Fixes #223
Browse files Browse the repository at this point in the history
  • Loading branch information
liliakai committed May 15, 2015
1 parent b8c5bc2 commit fe1d78b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
29 changes: 12 additions & 17 deletions js/libtextsecure.js
Original file line number Diff line number Diff line change
Expand Up @@ -38322,27 +38322,22 @@ axolotlInternal.RecipientRecord = function() {
})();

;(function() {
'use strict';
window.textsecure = window.textsecure || {};
window.textsecure.protobuf = {};

function loadProtoBufs(filename) {
return dcodeIO.ProtoBuf.loadProtoFile({root: '/protos', file: filename}).build('textsecure');
return dcodeIO.ProtoBuf.loadProtoFile({root: '/protos', file: filename}, function(error, result) {
var protos = result.build('textsecure');
for (var protoName in protos) {
textsecure.protobuf[protoName] = protos[protoName];
}
});
};

var pushMessages = loadProtoBufs('IncomingPushMessageSignal.proto');
var subProtocolMessages = loadProtoBufs('SubProtocol.proto');
var deviceMessages = loadProtoBufs('DeviceMessages.proto');

window.textsecure = window.textsecure || {};
window.textsecure.protobuf = {
IncomingPushMessageSignal : pushMessages.IncomingPushMessageSignal,
PushMessageContent : pushMessages.PushMessageContent,
ProvisioningUuid : deviceMessages.ProvisioningUuid,
ProvisionEnvelope : deviceMessages.ProvisionEnvelope,
ProvisionMessage : deviceMessages.ProvisionMessage,
DeviceControl : deviceMessages.DeviceControl,
WebSocketResponseMessage : subProtocolMessages.WebSocketResponseMessage,
WebSocketRequestMessage : subProtocolMessages.WebSocketRequestMessage,
WebSocketMessage : subProtocolMessages.WebSocketMessage
};
loadProtoBufs('IncomingPushMessageSignal.proto');
loadProtoBufs('SubProtocol.proto');
loadProtoBufs('DeviceMessages.proto');
})();

/* vim: ts=4:sw=4:expandtab
Expand Down
29 changes: 12 additions & 17 deletions libtextsecure/protobufs.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
;(function() {
'use strict';
window.textsecure = window.textsecure || {};
window.textsecure.protobuf = {};

function loadProtoBufs(filename) {
return dcodeIO.ProtoBuf.loadProtoFile({root: '/protos', file: filename}).build('textsecure');
return dcodeIO.ProtoBuf.loadProtoFile({root: '/protos', file: filename}, function(error, result) {
var protos = result.build('textsecure');
for (var protoName in protos) {
textsecure.protobuf[protoName] = protos[protoName];
}
});
};

var pushMessages = loadProtoBufs('IncomingPushMessageSignal.proto');
var subProtocolMessages = loadProtoBufs('SubProtocol.proto');
var deviceMessages = loadProtoBufs('DeviceMessages.proto');

window.textsecure = window.textsecure || {};
window.textsecure.protobuf = {
IncomingPushMessageSignal : pushMessages.IncomingPushMessageSignal,
PushMessageContent : pushMessages.PushMessageContent,
ProvisioningUuid : deviceMessages.ProvisioningUuid,
ProvisionEnvelope : deviceMessages.ProvisionEnvelope,
ProvisionMessage : deviceMessages.ProvisionMessage,
DeviceControl : deviceMessages.DeviceControl,
WebSocketResponseMessage : subProtocolMessages.WebSocketResponseMessage,
WebSocketRequestMessage : subProtocolMessages.WebSocketRequestMessage,
WebSocketMessage : subProtocolMessages.WebSocketMessage
};
loadProtoBufs('IncomingPushMessageSignal.proto');
loadProtoBufs('SubProtocol.proto');
loadProtoBufs('DeviceMessages.proto');
})();

0 comments on commit fe1d78b

Please sign in to comment.