compatible with engine.io 0.7.9
This commit is contained in:
@@ -15,19 +15,12 @@ import java.net.URISyntaxException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class WebSocket extends Transport {
|
public class WebSocket extends Transport {
|
||||||
|
|
||||||
public static final String NAME = "websocket";
|
public static final String NAME = "websocket";
|
||||||
|
|
||||||
private WebSocketClient socket;
|
private WebSocketClient socket;
|
||||||
private Future bufferedAmountId;
|
|
||||||
|
|
||||||
private ScheduledExecutorService drainScheduler = Executors.newSingleThreadScheduledExecutor();
|
|
||||||
|
|
||||||
|
|
||||||
public WebSocket(Options opts) {
|
public WebSocket(Options opts) {
|
||||||
@@ -101,31 +94,13 @@ public class WebSocket extends Transport {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.socket.getConnection().hasBufferedData()) {
|
// fake drain
|
||||||
this.bufferedAmountId = this.drainScheduler.scheduleAtFixedRate(new Runnable() {
|
// defer to next tick to allow Socket to clear writeBuffer
|
||||||
@Override
|
EventThread.nextTick(ondrain);
|
||||||
public void run() {
|
|
||||||
EventThread.exec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!self.socket.getConnection().hasBufferedData()) {
|
|
||||||
self.bufferedAmountId.cancel(true);
|
|
||||||
ondrain.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 50, 50, TimeUnit.MILLISECONDS);
|
|
||||||
} else {
|
|
||||||
EventThread.nextTick(ondrain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClose() {
|
protected void onClose() {
|
||||||
if (this.bufferedAmountId != null) {
|
|
||||||
this.bufferedAmountId.cancel(true);
|
|
||||||
}
|
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"engine.io": "0.7.3"
|
"engine.io": "0.7.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user