Skip to content

Commit

Permalink
Cosmetic change.
Browse files Browse the repository at this point in the history
- Uppercase 'C' (constants), 'Utils', and 'Exceptions' module names.
  • Loading branch information
jmillan committed Feb 1, 2013
1 parent a612987 commit 6f4b067
Show file tree
Hide file tree
Showing 22 changed files with 431 additions and 431 deletions.
6 changes: 3 additions & 3 deletions grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module.exports = function(grunt) {
src: [
"src/head.js",
"src/EventEmitter.js",
"src/constants.js",
"src/exceptions.js",
"src/Constants.js",
"src/Exceptions.js",
"src/timers.js",
"src/Transport.js",
"src/Parser.js",
Expand All @@ -33,7 +33,7 @@ module.exports = function(grunt) {
"src/MediaSession.js",
"src/Message.js",
"src/UA.js",
"src/utils.js",
"src/Utils.js",
"src/SanityCheck.js",
"src/DigestAuthentication.js",
"src/tail.js"
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js → src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @augments JsSIP
*/

JsSIP.c = {
JsSIP.C= {
USER_AGENT: JsSIP.name() +' '+ JsSIP.version(),

// Modules and Classes names for logging purposes
Expand Down
32 changes: 16 additions & 16 deletions src/Dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
* @param {JsSIP.Session} session
* @param {JsSIP.IncomingRequest|JsSIP.IncomingResponse} msg
* @param {Enum} type UAC / UAS
* @param {Enum} state JsSIP.c.DIALOG_EARLY / JsSIP.c.DIALOG_CONFIRMED
* @param {Enum} state JsSIP.C.DIALOG_EARLY / JsSIP.C.DIALOG_CONFIRMED
*/

// RFC 3261 12.1
JsSIP.Dialog = function(session, msg, type, state) {
var contact;

if(msg.countHeader('contact') === 0) {
console.log(JsSIP.c.LOG_DIALOG + 'No contact header field. Silently discarded');
console.log(JsSIP.C.LOG_DIALOG + 'No contact header field. Silently discarded');
return false;
}

if(msg instanceof JsSIP.IncomingResponse) {
state = (msg.status_code < 200) ? JsSIP.c.DIALOG_EARLY : JsSIP.c.DIALOG_CONFIRMED;
state = (msg.status_code < 200) ? JsSIP.C.DIALOG_EARLY : JsSIP.C.DIALOG_CONFIRMED;
} else if (msg instanceof JsSIP.IncomingRequest) {
// Create confirmed dialog if state is not defined
state = state || JsSIP.c.DIALOG_CONFIRMED;
state = state || JsSIP.C.DIALOG_CONFIRMED;
} else {
console.log(JsSIP.c.LOG_DIALOG + 'Received message is not a request neither a response');
console.log(JsSIP.C.LOG_DIALOG + 'Received message is not a request neither a response');
return false;
}

Expand Down Expand Up @@ -70,7 +70,7 @@ JsSIP.Dialog = function(session, msg, type, state) {

this.session = session;
session.ua.dialogs[this.id.toString()] = this;
console.log(JsSIP.c.LOG_DIALOG +'New ' + type + ' dialog created: ' + this.state);
console.log(JsSIP.C.LOG_DIALOG +'New ' + type + ' dialog created: ' + this.state);
};

JsSIP.Dialog.prototype = {
Expand All @@ -79,9 +79,9 @@ JsSIP.Dialog.prototype = {
* @param {Enum} UAC/UAS
*/
update: function(message, type) {
this.state = JsSIP.c.DIALOG_CONFIRMED;
this.state = JsSIP.C.DIALOG_CONFIRMED;

console.log(JsSIP.c.LOG_DIALOG +'dialog state changed to \'CONFIRMED\' state');
console.log(JsSIP.C.LOG_DIALOG +'dialog state changed to \'CONFIRMED\' state');

if(type === 'UAC') {
// RFC 3261 13.2.2.4
Expand All @@ -90,7 +90,7 @@ JsSIP.Dialog.prototype = {
},

terminate: function() {
console.log(JsSIP.c.LOG_DIALOG +'dialog state: ' + this.id.toString() + ' deleted');
console.log(JsSIP.C.LOG_DIALOG +'dialog state: ' + this.id.toString() + ' deleted');
delete this.session.ua.dialogs[this.id.toString()];
},

Expand All @@ -107,7 +107,7 @@ JsSIP.Dialog.prototype = {

if(!this.local_seqnum) { this.local_seqnum = Math.floor(Math.random() * 10000); }

cseq = (method === JsSIP.c.CANCEL || method === JsSIP.c.ACK) ? this.local_seqnum : this.local_seqnum += 1;
cseq = (method === JsSIP.C.CANCEL || method === JsSIP.C.ACK) ? this.local_seqnum : this.local_seqnum += 1;

request = new JsSIP.OutgoingRequest(
method,
Expand Down Expand Up @@ -136,9 +136,9 @@ JsSIP.Dialog.prototype = {
checkInDialogRequest: function(request) {
if(!this.remote_seqnum) {
this.remote_seqnum = request.cseq;
} else if(request.method !== JsSIP.c.INVITE && request.cseq < this.remote_seqnum) {
} else if(request.method !== JsSIP.C.INVITE && request.cseq < this.remote_seqnum) {
//Do not try to reply to an ACK request.
if (request.method !== JsSIP.c.ACK) {
if (request.method !== JsSIP.C.ACK) {
request.reply(500);
}
return false;
Expand All @@ -148,9 +148,9 @@ JsSIP.Dialog.prototype = {

switch(request.method) {
// RFC3261 14.2 Modifying an Existing Session -UAS BEHAVIOR-
case JsSIP.c.INVITE:
case JsSIP.C.INVITE:
if(request.cseq < this.remote_seqnum) {
if(this.state === JsSIP.c.DIALOG_EARLY) {
if(this.state === JsSIP.C.DIALOG_EARLY) {
var retryAfter = (Math.random() * 10 | 0) + 1;
request.reply(500, null, ['Retry-After:'+ retryAfter]);
} else {
Expand All @@ -159,7 +159,7 @@ JsSIP.Dialog.prototype = {
return false;
}
// RFC3261 14.2
if(this.state === JsSIP.c.DIALOG_EARLY) {
if(this.state === JsSIP.C.DIALOG_EARLY) {
request.reply(491);
return false;
}
Expand All @@ -168,7 +168,7 @@ JsSIP.Dialog.prototype = {
this.remote_target = request.parseHeader('contact').uri;
}
break;
case JsSIP.c.NOTIFY:
case JsSIP.C.NOTIFY:
// RFC6655 3.2 Replace the dialog`s remote target URI
if(request.hasHeader('contact')) {
this.remote_target = request.parseHeader('contact').uri;
Expand Down
10 changes: 5 additions & 5 deletions src/DigestAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ JsSIP.DigestAuthentication.prototype.authenticate = function(password) {
}

// HA1 = MD5(A1) = MD5(username:realm:password)
ha1 = JsSIP.utils.MD5(this.username + ":" + this.realm + ":" + password);
ha1 = JsSIP.Utils.MD5(this.username + ":" + this.realm + ":" + password);

if (this.qop === 'auth' || this.qop === null) {
// HA2 = MD5(A2) = MD5(method:digestURI)
ha2 = JsSIP.utils.MD5(this.method + ":" + this.uri);
ha2 = JsSIP.Utils.MD5(this.method + ":" + this.uri);

} else if (this.qop === 'auth-int') {
// HA2 = MD5(A2) = MD5(method:digestURI:MD5(entityBody))
ha2 = JsSIP.utils.MD5(this.method + ":" + this.uri + ":" + JsSIP.utils.MD5(this.body ? this.body : ""));
ha2 = JsSIP.Utils.MD5(this.method + ":" + this.uri + ":" + JsSIP.Utils.MD5(this.body ? this.body : ""));
}

if(this.qop === 'auth' || this.qop === 'auth-int') {
// response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2)
this.response = JsSIP.utils.MD5(ha1 + ":" + this.nonce + ":" + this.decimalToHex(this.nc) + ":" + this.cnonce + ":" + this.qop + ":" + ha2);
this.response = JsSIP.Utils.MD5(ha1 + ":" + this.nonce + ":" + this.decimalToHex(this.nc) + ":" + this.cnonce + ":" + this.qop + ":" + ha2);
} else {
// response = MD5(HA1:nonce:HA2)
this.response = JsSIP.utils.MD5(ha1 + ":" + this.nonce + ":" + ha2);
this.response = JsSIP.Utils.MD5(ha1 + ":" + this.nonce + ":" + ha2);
}

return this.toString();
Expand Down
10 changes: 5 additions & 5 deletions src/EventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ JsSIP.EventEmitter.prototype = {
this.onceNotFired = []; // Array containing events with _once_ defined tat didn't fire yet.
this.maxListeners = 10;
this.events.newListener = function(event) { // Default newListener callback
console.log(JsSIP.c.LOG_EVENT_EMITTER +'new Listener added to event: '+ event);
console.log(JsSIP.C.LOG_EVENT_EMITTER +'new Listener added to event: '+ event);
};

while (i--) {
console.log(JsSIP.c.LOG_EVENT_EMITTER +'Adding event: '+ events[i]);
console.log(JsSIP.C.LOG_EVENT_EMITTER +'Adding event: '+ events[i]);
this.events[events[i]] = [];
}
},
Expand All @@ -38,7 +38,7 @@ JsSIP.EventEmitter.prototype = {
*/
checkEvent: function(event) {
if (!this.events[event]) {
console.log(JsSIP.c.LOG_EVENT_EMITTER +'No event named: '+ event);
console.log(JsSIP.C.LOG_EVENT_EMITTER +'No event named: '+ event);
return false;
} else {
return true;
Expand All @@ -56,7 +56,7 @@ JsSIP.EventEmitter.prototype = {
}

if (this.events[event].length >= this.maxListeners) {
console.log(JsSIP.c.LOG_EVENT_EMITTER +'Max Listeners exceeded for event: '+ event);
console.log(JsSIP.C.LOG_EVENT_EMITTER +'Max Listeners exceeded for event: '+ event);
}

this.events[event].push(listener);
Expand Down Expand Up @@ -144,7 +144,7 @@ JsSIP.EventEmitter.prototype = {
return;
}

console.log(JsSIP.c.LOG_EVENT_EMITTER +'Emitting event: '+event);
console.log(JsSIP.C.LOG_EVENT_EMITTER +'Emitting event: '+event);

listeners = this.events[event];
length = listeners.length;
Expand Down
16 changes: 8 additions & 8 deletions src/exceptions.js → src/Exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
* @augments JsSIP
*/

JsSIP.exceptions = {
JsSIP.Exceptions= {
ConfigurationError: (function(){
var exception = function() {
this.code = 1;
this.name = 'CONFIGURATION_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand All @@ -23,7 +23,7 @@ JsSIP.exceptions = {
var exception = function() {
this.code = 2;
this.name = 'NOT_READY_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand All @@ -33,7 +33,7 @@ JsSIP.exceptions = {
var exception = function() {
this.code = 3;
this.name = 'INVALID_TARGET_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand All @@ -43,7 +43,7 @@ JsSIP.exceptions = {
var exception = function(){
this.code = 4;
this.name = 'WEBRTC_NO_SUPPORTED_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand All @@ -53,7 +53,7 @@ JsSIP.exceptions = {
var exception = function() {
this.code = 5;
this.name = 'INVALID_STATE_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand All @@ -63,7 +63,7 @@ JsSIP.exceptions = {
var exception = function() {
this.code = 6;
this.name = 'INVALID_METHOD_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand All @@ -73,7 +73,7 @@ JsSIP.exceptions = {
var exception = function() {
this.code = 7;
this.name = 'INVALID_VALUE_ERROR';
this.message = JsSIP.c.LOG_EXCEPTION + this.code;
this.message = JsSIP.C.LOG_EXCEPTION + this.code;
};
exception.prototype = new Error();
return exception;
Expand Down
2 changes: 1 addition & 1 deletion src/InDialogRequestSender.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ JsSIP.InDialogRequestSender.prototype = {
receiveResponse: function(response) {
// RFC3261 14.1. Terminate the dialog if a 408 or 481 is received from a re-Invite.
if (response.status_code === 408 || response.status_code === 481) {
this.applicant.session.ended('remote', response, JsSIP.c.causes.IN_DIALOG_408_OR_481);
this.applicant.session.ended('remote', response, JsSIP.C.causes.IN_DIALOG_408_OR_481);
}
this.applicant.receiveResponse(response);
}
Expand Down
20 changes: 10 additions & 10 deletions src/MediaSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ JsSIP.MediaSession.prototype = {

this.peerConnection.onicecandidate = function(event) {
if (event.candidate) {
console.log(JsSIP.c.LOG_MEDIA_SESSION +'ICE candidate received: '+ event.candidate.candidate);
console.log(JsSIP.C.LOG_MEDIA_SESSION +'ICE candidate received: '+ event.candidate.candidate);
} else {
console.info(JsSIP.c.LOG_MEDIA_SESSION +'No more ICE candidate');
console.log(JsSIP.c.LOG_MEDIA_SESSION +'Peerconnection status: '+ this.readyState);
console.log(JsSIP.c.LOG_MEDIA_SESSION +'Ice Status: '+ this.iceState);
console.info(JsSIP.C.LOG_MEDIA_SESSION +'No more ICE candidate');
console.log(JsSIP.C.LOG_MEDIA_SESSION +'Peerconnection status: '+ this.readyState);
console.log(JsSIP.C.LOG_MEDIA_SESSION +'Ice Status: '+ this.iceState);
if (!sent) { // Execute onSuccess just once.
sent = true;
onSuccess();
Expand All @@ -139,7 +139,7 @@ JsSIP.MediaSession.prototype = {
};

this.peerConnection.onopen = function() {
console.log(JsSIP.c.LOG_MEDIA_SESSION +'Media session opened');
console.log(JsSIP.C.LOG_MEDIA_SESSION +'Media session opened');
};

this.peerConnection.onaddstream = function(mediaStreamEvent) {
Expand All @@ -151,7 +151,7 @@ JsSIP.MediaSession.prototype = {
};

this.peerConnection.onremovestream = function(stream) {
console.log(JsSIP.c.LOG_MEDIA_SESSION +'Stream removed: '+ stream);
console.log(JsSIP.C.LOG_MEDIA_SESSION +'Stream removed: '+ stream);
};

this.peerConnection.onstatechange = function() {
Expand All @@ -161,7 +161,7 @@ JsSIP.MediaSession.prototype = {
},

close: function() {
console.log(JsSIP.c.LOG_MEDIA_SESSION +'Closing peerConnection');
console.log(JsSIP.C.LOG_MEDIA_SESSION +'Closing peerConnection');
if(this.peerConnection) {
this.peerConnection.close();

Expand All @@ -180,7 +180,7 @@ JsSIP.MediaSession.prototype = {
var self = this;

function getSuccess(stream) {
console.log(JsSIP.c.LOG_MEDIA_SESSION +"Got stream " + stream);
console.log(JsSIP.C.LOG_MEDIA_SESSION +"Got stream " + stream);

//Save the localMedia in order to revoke access to devices later.
self.localMedia = stream;
Expand All @@ -198,7 +198,7 @@ JsSIP.MediaSession.prototype = {
}

// Get User Media
console.log(JsSIP.c.LOG_MEDIA_SESSION +"Requesting access to local media.");
console.log(JsSIP.C.LOG_MEDIA_SESSION +"Requesting access to local media.");
navigator.webkitGetUserMedia(mediaType, getSuccess, getFailure);

},
Expand All @@ -212,7 +212,7 @@ JsSIP.MediaSession.prototype = {
*/
onMessage: function(type, sdp, onSuccess, onFailure) {
if (type === 'offer') {
console.log(JsSIP.c.LOG_MEDIA_SESSION +'re-Invite received');
console.log(JsSIP.C.LOG_MEDIA_SESSION +'re-Invite received');
} else if (type === 'answer') {
this.peerConnection.setRemoteDescription(
new window.RTCSessionDescription({type:'answer', sdp:sdp}), onSuccess, onFailure);
Expand Down
Loading

0 comments on commit 6f4b067

Please sign in to comment.