public synchronized void poll(final Channel channel, final TransportMessage message) throws TransportException { throw new TransportException("Not implemented"); }
protected void onError(Channel channel, Throwable throwable) { log.error(throwable, "Websocket connection error"); channel.onError(connectMessage, new RuntimeException("Websocket connection error", throwable)); getStatusHandler().handleException(new TransportException("Websocket connection error: " + throwable.getMessage())); } }
protected void onError(Channel channel, Throwable throwable) { log.error(throwable, "Websocket connection error"); channel.onError(connectMessage, new RuntimeException("Websocket connection error", throwable)); getStatusHandler().handleException(new TransportException("Websocket connection error: " + throwable.getMessage())); } }
@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; }
@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; }
public void start() { Platform platform = Platform.getInstance(); platform.setContext(context); if (remotingTransport == null) remotingTransport = Platform.getInstance().newRemotingTransport(); if (!remotingTransport.isStarted() && !remotingTransport.start()) throw new TransportException("Could not start remoting transport: " + remotingTransport); if (messagingTransport == null) { messagingTransport = Platform.getInstance().newMessagingTransport(); if (messagingTransport == null) messagingTransport = remotingTransport; } else if (!messagingTransport.isStarted() && !messagingTransport.start()) throw new TransportException("Could not start messaging transport: " + messagingTransport); if (aliasRegistry == null) aliasRegistry = new ClientAliasRegistry(); if (scanPackageNames != null) aliasRegistry.scan(scanPackageNames); }
@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 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; }
@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 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 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 synchronized void stop() { if (webSocketClientFactory == null) return; log.info("Stopping Jetty WebSocketClient transport..."); super.stop(); try { webSocketClientFactory.stop(); } catch (Exception e) { getStatusHandler().handleException(new TransportException("Could not stop Jetty WebSocketFactory", e)); log.error(e, "Jetty WebSocketClient failed to stop properly."); } finally { webSocketClientFactory = null; } log.info("Jetty WebSocketClient transport stopped."); } }
@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)); } }
@Override public synchronized boolean start() { if (isStarted()) return true; log.info("Starting WebSocket transport..."); try { webSocketContainer = createContainer(); webSocketContainer.setDefaultMaxBinaryMessageBufferSize(getMaxMessageSize()); log.info("WebSocket transport started."); return true; } catch (Exception e) { webSocketContainer = null; getStatusHandler().handleException(new TransportException("Could not start WebSocket Endpoint", e)); log.error(e, "WebSocket transport failed to start."); return false; } }
@Override public synchronized boolean start() { if (isStarted()) return true; log.info("Starting WebSocket transport..."); try { webSocketContainer = createContainer(); webSocketContainer.setDefaultMaxBinaryMessageBufferSize(getMaxMessageSize()); log.info("WebSocket transport started."); return true; } catch (Exception e) { webSocketContainer = null; getStatusHandler().handleException(new TransportException("Could not start WebSocket Endpoint", e)); log.error(e, "WebSocket transport failed to start."); return false; } }
@Override public synchronized void stop() { if (webSocketContainer == null) return; log.info("Stopping WebSocket transport..."); setStopping(true); super.stop(); try { closeContainer(webSocketContainer); } catch (Exception e) { getStatusHandler().handleException(new TransportException("Could not stop WebSocket", e)); log.error(e, "WebSocket failed to stop properly."); } finally { webSocketContainer = null; setStopping(false); } log.info("WebSocket transport stopped."); }
@Override public synchronized void stop() { if (webSocketClientFactory == null) return; log.info("Stopping Jetty WebSocketClient transport..."); super.stop(); try { setStopping(true); webSocketClientFactory.stop(); } catch (Exception e) { getStatusHandler().handleException(new TransportException("Could not stop Jetty WebSocketFactory", e)); log.error(e, "Jetty WebSocketClient failed to stop properly."); } finally { setStopping(false); } log.info("Jetty WebSocketClient transport stopped."); }
@Override public synchronized void stop() { if (webSocketClientFactory == null) return; log.info("Stopping Jetty WebSocketClient transport..."); super.stop(); try { setStopping(true); webSocketClientFactory.stop(); } catch (Exception e) { getStatusHandler().handleException(new TransportException("Could not stop Jetty WebSocketFactory", e)); log.error(e, "Jetty WebSocketClient failed to stop properly."); } finally { setStopping(false); } log.info("Jetty WebSocketClient transport stopped."); }
@Override public synchronized void stop() { if (webSocketContainer == null) return; log.info("Stopping WebSocket transport..."); setStopping(true); super.stop(); try { closeContainer(webSocketContainer); } catch (Exception e) { getStatusHandler().handleException(new TransportException("Could not stop WebSocket", e)); log.error(e, "WebSocket failed to stop properly."); } finally { webSocketContainer = null; setStopping(false); } log.info("WebSocket transport stopped."); }
@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)); } }