add a test for the transport option
This commit is contained in:
@@ -31,9 +31,6 @@ public abstract class Socket extends Emitter {
|
||||
put(CLOSED, "closed");
|
||||
}};
|
||||
|
||||
public static final String POLLING = "polling";
|
||||
public static final String WEBSOCKET = "websocket";
|
||||
|
||||
public static final String EVENT_OPEN = "open";
|
||||
public static final String EVENT_CLOSE = "close";
|
||||
public static final String EVENT_HANDSHAKE = "handshake";
|
||||
@@ -116,8 +113,8 @@ public abstract class Socket extends Emitter {
|
||||
this.path = (opts.path != null ? opts.path : "/engine.io").replaceAll("/$", "") + "/";
|
||||
this.timestampParam = opts.timestampParam != null ? opts.timestampParam : "t";
|
||||
this.timestampRequests = opts.timestampRequests;
|
||||
this.transports = new ArrayList<String>(Arrays.asList(
|
||||
opts.transports != null ? opts.transports : new String[] {POLLING, WEBSOCKET}));
|
||||
this.transports = new ArrayList<String>(Arrays.asList(opts.transports != null ?
|
||||
opts.transports : new String[] {Polling.NAME, WebSocket.NAME}));
|
||||
this.policyPort = opts.policyPort != 0 ? opts.policyPort : 843;
|
||||
|
||||
Socket.sockets.add(this);
|
||||
@@ -151,9 +148,9 @@ public abstract class Socket extends Emitter {
|
||||
opts.timestampParam = this.timestampParam;
|
||||
opts.policyPort = this.policyPort;
|
||||
|
||||
if (WEBSOCKET.equals(name)) {
|
||||
if (WebSocket.NAME.equals(name)) {
|
||||
return new WebSocket(opts);
|
||||
} else if (POLLING.equals(name)) {
|
||||
} else if (Polling.NAME.equals(name)) {
|
||||
return new PollingXHR(opts);
|
||||
}
|
||||
|
||||
@@ -513,7 +510,7 @@ public abstract class Socket extends Emitter {
|
||||
}
|
||||
}
|
||||
|
||||
private List<String > filterUpgrades(List<String> upgrades) {
|
||||
/*package*/ List<String > filterUpgrades(List<String> upgrades) {
|
||||
List<String> filteredUpgrades = new ArrayList<String>();
|
||||
for (String upgrade : upgrades) {
|
||||
if (this.transports.contains(upgrade)) {
|
||||
@@ -555,7 +552,7 @@ public abstract class Socket extends Emitter {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Sockets extends ConcurrentLinkedQueue<Socket> {
|
||||
public static class Sockets extends ArrayList<Socket> {
|
||||
|
||||
public static final String EVENT_ADD = "add";
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.github.nkzawa.engineio.client.transports;
|
||||
|
||||
|
||||
import com.github.nkzawa.engineio.client.Socket;
|
||||
import com.github.nkzawa.engineio.client.Transport;
|
||||
import com.github.nkzawa.engineio.client.Util;
|
||||
import com.github.nkzawa.engineio.parser.Packet;
|
||||
@@ -16,6 +15,8 @@ abstract public class Polling extends Transport {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("engine.io-client:polling");
|
||||
|
||||
public static final String NAME = "polling";
|
||||
|
||||
public static final String EVENT_POLL = "poll";
|
||||
public static final String EVENT_POLL_COMPLETE = "pollComplete";
|
||||
|
||||
@@ -24,7 +25,7 @@ abstract public class Polling extends Transport {
|
||||
|
||||
public Polling(Options opts) {
|
||||
super(opts);
|
||||
this.name = Socket.POLLING;
|
||||
this.name = NAME;
|
||||
}
|
||||
|
||||
protected void doOpen() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.github.nkzawa.engineio.client.transports;
|
||||
|
||||
|
||||
import com.github.nkzawa.engineio.client.Socket;
|
||||
import com.github.nkzawa.engineio.client.Transport;
|
||||
import com.github.nkzawa.engineio.client.Util;
|
||||
import com.github.nkzawa.engineio.parser.Packet;
|
||||
@@ -22,6 +21,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WebSocket extends Transport {
|
||||
|
||||
public static final String NAME = "websocket";
|
||||
|
||||
private WebSocketClient socket;
|
||||
private Future bufferedAmountId;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class WebSocket extends Transport {
|
||||
|
||||
public WebSocket(Options opts) {
|
||||
super(opts);
|
||||
this.name = Socket.WEBSOCKET;
|
||||
this.name = NAME;
|
||||
}
|
||||
|
||||
protected void doOpen() {
|
||||
|
||||
Reference in New Issue
Block a user