@Override public void setStatusHandler(TransportStatusHandler statusHandler) { if (statusHandler == null) statusHandler = new NoopEngineStatusHandler(); this.statusHandler = statusHandler; }
public void stop(boolean stopTransports) { if (stopTransports) { if (remotingTransport != null && remotingTransport.isStarted()) { remotingTransport.stop(); remotingTransport = null; } if (messagingTransport != null && messagingTransport.isStarted()) { messagingTransport.stop(); messagingTransport = null; } } }
@Override public String toString() { return super.toString() + " (code=" + status + ")"; } }
public void failed(Exception e) { if (!message.isConnect()) getStatusHandler().handleIO(false); channel.onError(message, e); getStatusHandler().handleException(new TransportIOException(message, "Request failed", e)); }
@Override public void connect(final Channel channel, final TransportMessage transportMessage) { try { log.info("Connecting to websocket %s sessionId %s", channel.getUri(), transportMessage.getSessionId()); webSocketContainer.connectToServer(new GravityWebSocketEndpoint(channel), new GravityWebSocketEndpointConfig(channel, transportMessage), channel.getUri()); } catch (Exception e) { log.error(e, "Could not connect to uri %s", channel.getUri()); getStatusHandler().handleException(new TransportException("Could not connect to uri " + channel.getUri(), e)); } }
public void cancelled() { if (!message.isConnect()) getStatusHandler().handleIO(false); if (message.isDisconnect()) { channel.onDisconnect(); return; } channel.onCancelled(message); } });
@Override public synchronized void stop() { if (httpClient == null) return; log.info("Stopping Apache HttpAsyncClient transport..."); super.stop(); try { httpClient.close(); } catch (Exception e) { getStatusHandler().handleException(new TransportException("Could not stop Apache HttpAsyncClient", e)); log.error(e, "Apache HttpAsyncClient failed to stop properly."); } finally { httpClient = null; } log.info("Apache HttpAsyncClient transport stopped."); } }
@Override public RemotingChannel newRemotingChannel(String id, URI uri, int maxConcurrentRequests) { if (getRemotingTransport() == null) throw new RuntimeException("Remoting transport not defined, start the ChannelFactory first"); if (!getRemotingTransport().isStarted() && !getRemotingTransport().start()) throw new TransportException("Could not start remoting transport: " + getRemotingTransport()); RemotingChannel channel = defaultChannelBuilder.buildRemotingChannel(getRemotingChannelClass(), id, uri, maxConcurrentRequests, getRemotingTransport(), newMessagingCodec(AMF0Message.class)); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; }
public void cancelled() { if (!message.isConnect()) getStatusHandler().handleIO(false); channel.onCancelled(message); } });
public synchronized void poll(final Channel channel, final TransportMessage message) throws TransportException { throw new TransportException("Not implemented"); }
@Override public void stop() { synchronized (stopListeners) { for (TransportStopListener listener : stopListeners) { try { listener.onStop(this); } catch (Exception e) { } } stopListeners.clear(); } } }
public void failed(Exception e) { if (!message.isConnect()) getStatusHandler().handleIO(false); if (message.isDisconnect()) { channel.onDisconnect(); return; } channel.onError(message, e); getStatusHandler().handleException(new TransportIOException(message, "Request failed", e)); }
@Override public void connect(final Channel channel, final TransportMessage transportMessage) { try { log.info("Connecting to websocket %s sessionId %s", channel.getUri(), transportMessage.getSessionId()); webSocketContainer.connectToServer(new GravityWebSocketEndpoint(channel), new GravityWebSocketEndpointConfig(channel, transportMessage), channel.getUri()); } catch (Exception e) { log.error(e, "Could not connect to uri %s", channel.getUri()); getStatusHandler().handleException(new TransportException("Could not connect to uri " + channel.getUri(), e)); } }
public void cancelled() { if (!message.isConnect()) getStatusHandler().handleIO(false); if (message.isDisconnect()) { channel.onDisconnect(); return; } channel.onCancelled(message); } });
@Override public RemotingChannel newRemotingChannel(String id, ServerApp serverApp, int maxConcurrentRequests) { if (getRemotingTransport() == null) throw new RuntimeException("Remoting transport not defined, start the ChannelFactory first"); if (!getRemotingTransport().isStarted() && !getRemotingTransport().start()) throw new TransportException("Could not start remoting transport: " + getRemotingTransport()); RemotingChannel channel = defaultChannelBuilder.buildRemotingChannel(getRemotingChannelClass(), id, serverApp, maxConcurrentRequests, getRemotingTransport(), newMessagingCodec(AMF0Message.class)); if (defaultTimeToLive != null) channel.setDefaultTimeToLive(defaultTimeToLive); return channel; }
@Override public void setStatusHandler(TransportStatusHandler statusHandler) { if (statusHandler == null) statusHandler = new NoopEngineStatusHandler(); this.statusHandler = statusHandler; }
@Override public String toString() { return super.toString() + " (code=" + status + ")"; } }
public void failed(Exception e) { if (!message.isConnect()) getStatusHandler().handleIO(false); if (message.isDisconnect()) { channel.onDisconnect(); return; } channel.onError(message, e); getStatusHandler().handleException(new TransportIOException(message, "Request failed", e)); }
@Override public void setStatusHandler(TransportStatusHandler statusHandler) { if (statusHandler == null) statusHandler = new NoopEngineStatusHandler(); this.statusHandler = statusHandler; }
@Override public String toString() { return super.toString() + " (code=" + status + ")"; } }