Skip to content

Commit

Permalink
Fire UA 'newMessage' event for incoming MESSAGE requests regardless t…
Browse files Browse the repository at this point in the history
…hey are out of dialog or in-dialog.
  • Loading branch information
jmillan committed Nov 20, 2012
1 parent 1ab3423 commit d6428e7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ JsSIP.UA.prototype.receiveRequest = function(request) {
'Allow: '+ JsSIP.utils.getAllowedMethods(this),
'Accept: '+ JsSIP.c.ACCEPTED_BODY_TYPES
]);
} else if (method === JsSIP.c.MESSAGE) {
if (!this.checkEvent('newMessage') || this.listeners('newMessage').length === 0) {
request.reply(405, JsSIP.c.REASON_405, ['Allow: '+ JsSIP.utils.getAllowedMethods(this)]);
}
return;
}
message = new JsSIP.Message(this);
message.init_incoming(request);
}

// Initial Request
Expand All @@ -375,10 +383,6 @@ JsSIP.UA.prototype.receiveRequest = function(request) {
}

switch(method) {
case JsSIP.c.MESSAGE:
message = new JsSIP.Message(this);
message.init_incoming(request);
break;
case JsSIP.c.INVITE:
if(!JsSIP.utils.isWebRtcSupported()) {
console.warn(JsSIP.c.LOG_UA +'Call invitation received but rtcweb is not supported');
Expand Down

0 comments on commit d6428e7

Please sign in to comment.