Преглед изворни кода

Cleans up logging a bit.

j8
Boris Grozev пре 10 година
родитељ
комит
e380f88c77
2 измењених фајлова са 28 додато и 4 уклоњено
  1. 1
    4
      app.js
  2. 27
    0
      libs/strophe/strophe.util.js

+ 1
- 4
app.js Прегледај датотеку

@@ -121,8 +121,8 @@ function connect(jid, password) {
121 121
 
122 122
     var anonymousConnectionFailed = false;
123 123
     connection.connect(jid, password, function (status, msg) {
124
+        console.log('Strophe status changed to', Strophe.getStatusString(status));
124 125
         if (status === Strophe.Status.CONNECTED) {
125
-            console.log('connected');
126 126
             if (config.useStunTurn) {
127 127
                 connection.jingle.getStunAndTurnCredentials();
128 128
             }
@@ -135,7 +135,6 @@ function connect(jid, password) {
135 135
             if(msg === 'x-strophe-bad-non-anon-jid') {
136 136
                 anonymousConnectionFailed = true;
137 137
             }
138
-            console.log('status', status);
139 138
         } else if (status === Strophe.Status.DISCONNECTED) {
140 139
             if(anonymousConnectionFailed) {
141 140
                 // prompt user for username and password
@@ -145,8 +144,6 @@ function connect(jid, password) {
145 144
             // wrong password or username, prompt user
146 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 Прегледај датотеку

@@ -12,3 +12,30 @@ Strophe.log = function (level, msg) {
12 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…
Откажи
Сачувај