Support for sending and receiving verification sync messages

This adds a new method to message sender for sending verification sync messages
and a new event to message receiver representing incoming verification sync
messages. Currently the event handler just logs the message.

// FREEBIE
This commit is contained in:
lilia 2017-06-15 15:00:04 -07:00 committed by Scott Nonnenberg
parent 475d607fd0
commit 52481d1d13
4 changed files with 88 additions and 1 deletions

View file

@ -272,10 +272,23 @@ MessageReceiver.prototype.extend({
console.log('read messages',
'from', envelope.source + '.' + envelope.sourceDevice);
this.handleRead(syncMessage.read, envelope.timestamp);
} else if (syncMessage.verification) {
this.handleVerification(syncMessage.verification);
} else {
throw new Error('Got empty SyncMessage');
}
},
handleVerification: function(verification) {
for (var i = 0; i < verification.length; ++i) {
var ev = new Event('verification');
ev.verification = {
state: verification[i].state,
destination: verification[i].destination,
identityKey: verification[i].identityKey.toArrayBuffer()
};
this.dispatchEvent(ev);
}
},
handleRead: function(read, timestamp) {
for (var i = 0; i < read.length; ++i) {
var ev = new Event('read');