Cleans up logging a bit.

This commit is contained in:
Boris Grozev 2014-10-13 20:34:23 +03:00
parent d976bfaa30
commit e380f88c77
2 changed files with 28 additions and 4 deletions

5
app.js
View File

@ -121,8 +121,8 @@ function connect(jid, password) {
var anonymousConnectionFailed = false;
connection.connect(jid, password, function (status, msg) {
console.log('Strophe status changed to', Strophe.getStatusString(status));
if (status === Strophe.Status.CONNECTED) {
console.log('connected');
if (config.useStunTurn) {
connection.jingle.getStunAndTurnCredentials();
}
@ -135,7 +135,6 @@ function connect(jid, password) {
if(msg === 'x-strophe-bad-non-anon-jid') {
anonymousConnectionFailed = true;
}
console.log('status', status);
} else if (status === Strophe.Status.DISCONNECTED) {
if(anonymousConnectionFailed) {
// prompt user for username and password
@ -145,8 +144,6 @@ function connect(jid, password) {
// wrong password or username, prompt user
$(document).trigger('passwordrequired.main');
} else {
console.log('status', status);
}
});
}

View File

@ -12,3 +12,30 @@ Strophe.log = function (level, msg) {
break;
}
};
Strophe.getStatusString = function(status)
{
switch (status)
{
case Strophe.Status.ERROR:
return "ERROR";
case Strophe.Status.CONNECTING:
return "CONNECTING";
case Strophe.Status.CONNFAIL:
return "CONNFAIL";
case Strophe.Status.AUTHENTICATING:
return "AUTHENTICATING";
case Strophe.Status.AUTHFAIL:
return "AUTHFAIL";
case Strophe.Status.CONNECTED:
return "CONNECTED";
case Strophe.Status.DISCONNECTED:
return "DISCONNECTED";
case Strophe.Status.DISCONNECTING:
return "DISCONNECTING";
case Strophe.Status.ATTACHED:
return "ATTACHED";
default:
return "unknown";
}
};