final WaveSocket.WaveSocketCallback callback) {
if (useWebSocketAlt) {
return new WaveSocket() {
private final AtmosphereConnection socket
= new AtmosphereConnectionImpl(new AtmosphereConnectionListener() {
@Override
public void onConnect() {
callback.onConnect();
}
@Override
public void onDisconnect() {
callback.onDisconnect();
}
@Override
public void onMessage(String message) {
callback.onMessage(message);
}}, urlBase);
@Override
public void connect() {
socket.connect();
}
@Override
public void disconnect() {
socket.close();
}
@Override
public void sendMessage(String message) {
socket.sendMessage(message);
}
};
} else {
return new WaveSocket() {
final WebSocket socket = new WebSocket(new WebSocketCallback() {
@Override
public void onConnect() {
callback.onConnect();
}
@Override
public void onDisconnect() {
callback.onDisconnect();
}
@Override
public void onMessage(String message) {
callback.onMessage(message);
}
});
@Override
public void connect() {
socket.connect(urlBase + "socket");
}
@Override
public void disconnect() {
socket.close();
}
@Override
public void sendMessage(String message) {
socket.send(message);
}
};
}
}