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:
@@ -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');
|
||||
|
Reference in New Issue
Block a user