Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Commit

Permalink
Fix ringingTimeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Aug 21, 2014
1 parent d2cb744 commit 7d8269f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
25 changes: 12 additions & 13 deletions loop/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,20 @@ MessageHandler.prototype = {

// After the hello phase and as soon the callee is connected,
// the call changes to the "alerting" state.
if (currentState === "init") {
if (currentState === "init" || currentState === "half-initiated") {
self.broadcastState(session.callId, "init." + session.type,
timeoutTTL);
} else if (currentState === "half-initiated") {
self.broadcastState(session.callId, "init." + session.type);
// We are now in "alerting" mode.
setTimeout(function() {
self.storage.getCallState(session.callId, function(err, state) {
if (serverError(err, callback)) return;
if (state === "alerting" || state === "terminated") {
self.broadcastState(session.callId, "terminated:timeout");
}
});
}, self.conf.ringingDuration * 1000);
if (session.type === "callee") {
// We are now in "alerting" mode.
setTimeout(function() {
self.storage.getCallState(session.callId, function(err, state) {
if (serverError(err, callback)) return;
if (state === "alerting" || state === "terminated") {
self.broadcastState(session.callId, "terminated:timeout");
}
});
}, self.conf.ringingDuration * 1000);
}
}
});
});
Expand Down Expand Up @@ -322,7 +322,6 @@ MessageHandler.prototype = {
var self = this;
var parts = stateData.split(":");
var state = parts[0];

self.storage.setCallState(callId, state, ttl, function(err) {
if (serverError(err)) return;

Expand Down
1 change: 1 addition & 0 deletions test/websockets_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ describe('websockets', function() {

caller.on('message', function(data) {
var message = JSON.parse(data);
console.log(message);

This comment has been minimized.

Copy link
@almet

almet Aug 21, 2014

Contributor

oops ;)

if (callerMsgCount === 0) {
expect(message.messageType).eql("hello");
expect(message.state).eql("init");
Expand Down

0 comments on commit 7d8269f

Please sign in to comment.