public CometClientTransportWrapper() { // Websocket support not enabled yet if (webSocketsEnabled && WebSocketCometTransport.hasWebSocketSupport()) { transport = new WebSocketCometTransport(); } else { transport = GWT.create(CometTransport.class); } GWT.log("Created transport: " + transport.getClass().getName()); transport.initiate(AtmosphereClient.this, this); }
@Override public void onDisconnected() { cancelTimers(); if (transport instanceof WebSocketCometTransport && webSocketSuccessful == false) { // server doesn't support WebSocket's degrade the connection ... logger.info("Server does not support WebSockets"); transport = GWT.create(CometTransport.class); transport.initiate(AtmosphereClient.this, this); transport.connect(++connectionCount); } else { doOnDisconnected(this); } }
@Override public void onError(Throwable exception, boolean connected) { cancelTimers(); if (transport instanceof WebSocketCometTransport && webSocketSuccessful == false) { if (connected) { transport.disconnect(); } } else { doOnError(exception, connected, this); } }
public void disconnect() { cancelTimers(); transport.disconnect(); }
public void connect() { connectionTimer.schedule(connectionTimeout); transport.connect(++connectionCount); }
public void broadcast(List<?> messages) { transport.broadcast(messages); }
public void broadcast(Object message) { transport.broadcast(message); }
public void post(List<?> messages, AsyncCallback<Void> callback) { transport.post(messages, callback); }
public void post(Object message, AsyncCallback<Void> callback) { transport.post(message, callback); }
public void broadcast(List<Serializable> messages) { transport.broadcast(messages); }
public void broadcast(Serializable message) { transport.broadcast(message); }
public void post(List<Serializable> messages, AsyncCallback<Void> callback) { transport.post(messages, callback); }
public void post(Serializable message, AsyncCallback<Void> callback) { transport.post(message, callback); }