Skip to content

Commit

Permalink
Improved WebSocketClient
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Nov 17, 2016
1 parent 6f2b8f4 commit fba04a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/WebSocketClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* *
* hprose websocket client for HTML5. *
* *
* LastModified: Sep 29, 2016 *
* LastModified: Nov 16, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
Expand Down Expand Up @@ -101,7 +101,6 @@
ws = null;
}
function connect() {
_ready = new Future();
ws = new WebSocket(self.uri);
ws.binaryType = 'arraybuffer';
ws.onopen = onopen;
Expand All @@ -113,7 +112,7 @@
if (ws === null ||
ws.readyState === WebSocket.CLOSING ||
ws.readyState === WebSocket.CLOSED) {
connect();
_ready = new Future();
}
var id = getNextId();
var future = new Future();
Expand All @@ -135,6 +134,11 @@
else {
_requests.push([id, request]);
}
if (ws === null ||
ws.readyState === WebSocket.CLOSING ||
ws.readyState === WebSocket.CLOSED) {
connect();
}
if (env.oneway) { future.resolve(); }
return future;
}
Expand Down

0 comments on commit fba04a4

Please sign in to comment.