Skip to content

Commit

Permalink
State conflict resolution. Sadly not the Israeli-Palestinian one.
Browse files Browse the repository at this point in the history
If both peers call each other at the same time, one peer should
automatically accept the other's offer without further renegotiation.
  • Loading branch information
Gargron committed Dec 30, 2013
1 parent eb8ddd4 commit e36c842
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions public/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ var ContactsController = Ember.ArrayController.extend({
contact.set('signalingChannel', this.get('controllers.application.connection'));

contact.on('connection.incoming', function (accept) {
if (contact.get('waiting')) {
// While we receive this offer, we have actually sent an offer before
// We should reset our own offer, and just answer this one
contact.get('peer').close();
contact.init();
accept();
return;
}

var request = Ember.Object.create({ contact: contact, accept: accept });
self.get('controllers.calls.content').pushObject(request);
App.getAttention();
Expand Down
9 changes: 9 additions & 0 deletions public/js/controllers/contacts_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ var ContactsController = Ember.ArrayController.extend({
contact.set('signalingChannel', this.get('controllers.application.connection'));

contact.on('connection.incoming', function (accept) {
if (contact.get('waiting')) {
// While we receive this offer, we have actually sent an offer before
// We should reset our own offer, and just answer this one
contact.get('peer').close();
contact.init();
accept();
return;
}

var request = Ember.Object.create({ contact: contact, accept: accept });
self.get('controllers.calls.content').pushObject(request);
App.getAttention();
Expand Down

0 comments on commit e36c842

Please sign in to comment.