Skip to content

Commit 0245b17

Browse files
committed
Improved WebSocketClient
1 parent fba04a4 commit 0245b17

File tree

7 files changed

+20
-24
lines changed

7 files changed

+20
-24
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Ma Bingyao <[email protected]>",
33
"name": "hprose-html5",
4-
"version": "2.0.24",
4+
"version": "2.0.25",
55
"description": "Hprose is a High Performance Remote Object Service Engine.",
66
"keywords": [
77
"hprose",

dist/hprose-html5.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hprose-html5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hprose-html5.src.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Hprose for HTML5 v2.0.24
1+
// Hprose for HTML5 v2.0.25
22
// Copyright (c) 2008-2016 http://hprose.com
33
// Hprose is freely distributable under the MIT license.
44
// For all details and documentation:
@@ -5475,7 +5475,7 @@
54755475
* *
54765476
* hprose websocket client for HTML5. *
54775477
* *
5478-
* LastModified: Sep 29, 2016 *
5478+
* LastModified: Nov 18, 2016 *
54795479
* Author: Ma Bingyao <[email protected]> *
54805480
* *
54815481
\**********************************************************/
@@ -5573,11 +5573,6 @@
55735573
ws.onclose = onclose;
55745574
}
55755575
function sendAndReceive(request, env) {
5576-
if (ws === null ||
5577-
ws.readyState === WebSocket.CLOSING ||
5578-
ws.readyState === WebSocket.CLOSED) {
5579-
connect();
5580-
}
55815576
var id = getNextId();
55825577
var future = new Future();
55835578
_futures[id] = future;
@@ -5591,6 +5586,11 @@
55915586
return e instanceof TimeoutError;
55925587
});
55935588
}
5589+
if (ws === null ||
5590+
ws.readyState === WebSocket.CLOSING ||
5591+
ws.readyState === WebSocket.CLOSED) {
5592+
connect();
5593+
}
55945594
if (_count < 100) {
55955595
++_count;
55965596
_ready.then(function() { send(id, request); });

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "hprose-html5",
33
"filename": "hprose-html5.js",
4-
"version": "2.0.24",
4+
"version": "2.0.25",
55
"description": "Hprose is a High Performance Remote Object Service Engine.",
66
"homepage": "https://github.com/andot/hprose",
77
"keywords": [

src/CopyRight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Hprose for HTML5 v2.0.24
1+
// Hprose for HTML5 v2.0.25
22
// Copyright (c) 2008-2016 http://hprose.com
33
// Hprose is freely distributable under the MIT license.
44
// For all details and documentation:

src/WebSocketClient.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* *
1313
* hprose websocket client for HTML5. *
1414
* *
15-
* LastModified: Nov 16, 2016 *
15+
* LastModified: Nov 18, 2016 *
1616
* Author: Ma Bingyao <[email protected]> *
1717
* *
1818
\**********************************************************/
@@ -101,6 +101,7 @@
101101
ws = null;
102102
}
103103
function connect() {
104+
_ready = new Future();
104105
ws = new WebSocket(self.uri);
105106
ws.binaryType = 'arraybuffer';
106107
ws.onopen = onopen;
@@ -109,11 +110,6 @@
109110
ws.onclose = onclose;
110111
}
111112
function sendAndReceive(request, env) {
112-
if (ws === null ||
113-
ws.readyState === WebSocket.CLOSING ||
114-
ws.readyState === WebSocket.CLOSED) {
115-
_ready = new Future();
116-
}
117113
var id = getNextId();
118114
var future = new Future();
119115
_futures[id] = future;
@@ -127,18 +123,18 @@
127123
return e instanceof TimeoutError;
128124
});
129125
}
126+
if (ws === null ||
127+
ws.readyState === WebSocket.CLOSING ||
128+
ws.readyState === WebSocket.CLOSED) {
129+
connect();
130+
}
130131
if (_count < 100) {
131132
++_count;
132133
_ready.then(function() { send(id, request); });
133134
}
134135
else {
135136
_requests.push([id, request]);
136137
}
137-
if (ws === null ||
138-
ws.readyState === WebSocket.CLOSING ||
139-
ws.readyState === WebSocket.CLOSED) {
140-
connect();
141-
}
142138
if (env.oneway) { future.resolve(); }
143139
return future;
144140
}

0 commit comments

Comments
 (0)