Browse Source

Cleans up logging a bit.

j8
Boris Grozev 11 years ago
parent
commit
e380f88c77
2 changed files with 28 additions and 4 deletions
  1. 1
    4
      app.js
  2. 27
    0
      libs/strophe/strophe.util.js

+ 1
- 4
app.js View File

121
 
121
 
122
     var anonymousConnectionFailed = false;
122
     var anonymousConnectionFailed = false;
123
     connection.connect(jid, password, function (status, msg) {
123
     connection.connect(jid, password, function (status, msg) {
124
+        console.log('Strophe status changed to', Strophe.getStatusString(status));
124
         if (status === Strophe.Status.CONNECTED) {
125
         if (status === Strophe.Status.CONNECTED) {
125
-            console.log('connected');
126
             if (config.useStunTurn) {
126
             if (config.useStunTurn) {
127
                 connection.jingle.getStunAndTurnCredentials();
127
                 connection.jingle.getStunAndTurnCredentials();
128
             }
128
             }
135
             if(msg === 'x-strophe-bad-non-anon-jid') {
135
             if(msg === 'x-strophe-bad-non-anon-jid') {
136
                 anonymousConnectionFailed = true;
136
                 anonymousConnectionFailed = true;
137
             }
137
             }
138
-            console.log('status', status);
139
         } else if (status === Strophe.Status.DISCONNECTED) {
138
         } else if (status === Strophe.Status.DISCONNECTED) {
140
             if(anonymousConnectionFailed) {
139
             if(anonymousConnectionFailed) {
141
                 // prompt user for username and password
140
                 // prompt user for username and password
145
             // wrong password or username, prompt user
144
             // wrong password or username, prompt user
146
             $(document).trigger('passwordrequired.main');
145
             $(document).trigger('passwordrequired.main');
147
 
146
 
148
-        } else {
149
-            console.log('status', status);
150
         }
147
         }
151
     });
148
     });
152
 }
149
 }

+ 27
- 0
libs/strophe/strophe.util.js View File

12
             break;
12
             break;
13
     }
13
     }
14
 };
14
 };
15
+
16
+Strophe.getStatusString = function(status)
17
+{
18
+    switch (status)
19
+    {
20
+        case Strophe.Status.ERROR:
21
+            return "ERROR";
22
+        case Strophe.Status.CONNECTING:
23
+            return "CONNECTING";
24
+        case Strophe.Status.CONNFAIL:
25
+            return "CONNFAIL";
26
+        case Strophe.Status.AUTHENTICATING:
27
+            return "AUTHENTICATING";
28
+        case Strophe.Status.AUTHFAIL:
29
+            return "AUTHFAIL";
30
+        case Strophe.Status.CONNECTED:
31
+            return "CONNECTED";
32
+        case Strophe.Status.DISCONNECTED:
33
+            return "DISCONNECTED";
34
+        case Strophe.Status.DISCONNECTING:
35
+            return "DISCONNECTING";
36
+        case Strophe.Status.ATTACHED:
37
+            return "ATTACHED";
38
+        default:
39
+            return "unknown";
40
+    }
41
+};

Loading…
Cancel
Save