|
|
@@ -1,11 +1,15 @@
|
|
1
|
1
|
var ws, n = 0,
|
|
2
|
|
- timer,hidTel,hidCallID,hidActionID,
|
|
3
|
|
- cls = 0,lasttime = new Date().getTime(),obj = {},lockReconnect = false,
|
|
4
|
|
- directType,sendType,mesCont,eorrorConnect,errorState=false,reconnecTion,recon,loginOr=false;
|
|
|
2
|
+ timer,hidTel,hidCallID,hidActionID;
|
|
|
3
|
+var lockReconnect = false; //避免重复连接
|
|
|
4
|
+var obj = {};
|
|
|
5
|
+
|
|
|
6
|
+var cls = 0;
|
|
|
7
|
+var lasttime = new Date().getTime();
|
|
5
|
8
|
//创建scoket连接
|
|
6
|
9
|
function createWebSocket() {
|
|
7
|
10
|
try {
|
|
8
|
11
|
$("#top-search li i").removeClass("active");
|
|
|
12
|
+
|
|
9
|
13
|
Connect();
|
|
10
|
14
|
} catch(e) {
|
|
11
|
15
|
reconnect();
|
|
|
@@ -152,8 +156,12 @@ function reconnect() {
|
|
152
|
156
|
lockReconnect = false;
|
|
153
|
157
|
}, 2000);
|
|
154
|
158
|
}
|
|
|
159
|
+
|
|
155
|
160
|
//发送
|
|
156
|
161
|
function Send() {
|
|
|
162
|
+ if(ws.readyState != ws.OPEN) {
|
|
|
163
|
+ reconnect();
|
|
|
164
|
+ }
|
|
157
|
165
|
if(ws.readyState == ws.OPEN) {
|
|
158
|
166
|
console.log(new Date() + " send " + JSON.stringify(obj));
|
|
159
|
167
|
ws.send(JSON.stringify(obj));
|