@Override protected void wsTextReceived(NextFilter nextFilter, IoSession session, WsTextMessage wsText) throws Exception { IoBufferEx text = wsText.getBytes(); super.wsBinaryReceived(nextFilter, session, new WsBinaryMessage(text)); } }
@Override protected Object doFilterWriteWsBinary(NextFilter nextFilter, IoSession session, WriteRequest writeRequest, WsBinaryMessage wsBinary) throws Exception { IoBufferEx binary = wsBinary.getBytes(); return new WsTextMessage(binary); }
private void cancelCommand(final WsScheduledCommand command) { command.cancel((ScheduledFuture<?>) removeAttribute(command.getScheduledFutureKey())); }
WsTransport(Properties configuration) { extensionFactory = WebSocketExtensionFactory.newInstance(); acceptor = new WsAcceptor(extensionFactory); acceptor.setConfiguration(configuration); connector = new WsConnector(extensionFactory); }
private void scheduleCommand(WsScheduledCommand command, final long delay) { setAttribute(command.getScheduledFutureKey(), command.schedule(scheduler, delay, TimeUnit.SECONDS)); }
protected WsMessage emptyPongMessage(IoSessionEx session) throws Exception { WsPongMessage pong = new WsPongMessage(); return pong; }
public AbstractWsBridgeSession(int ioLayer, Thread ioThread, Executor ioExecutor, IoServiceEx service, IoProcessorEx<S> sIoProcessor, ResourceAddress localAddress, ResourceAddress remoteAddress, IoBufferAllocatorEx<B> allocator, Direction direction, ResultAwareLoginContext loginContext, List<WebSocketExtension> extensions) { super(ioLayer, ioThread, ioExecutor, service, sIoProcessor, localAddress, remoteAddress, allocator, direction); this.loginContext = loginContext; this.sessionTimeout = new WsSessionTimeoutCommand(this); this.extensions = extensions; }
public WsTextMessage(IoBufferEx buf, boolean fin) { super(fin); setBytes(buf); }
/** * Start up all the scheduled commands for this session. * */ public void startupScheduledCommands() { startupSessionTimeoutCommand(); }
@Override public void operationComplete(IoFuture future) { log("Session timed out."); } });
@Override public void reset(final Throwable cause) { super.reset(cause); } }
/** * When this session closes, one should call this command * to shutdown the scheduled commands */ public void shutdownScheduledCommands() { // Cancel the commands (releasing session references) cancelSessionTimeoutCommand(); }
public WsContinuationMessage(IoBufferEx buf, boolean fin) { super(fin); setBytes(buf); }
@Override public WriteFuture write(Object message) { return super.write(message); }
@Override public IoSessionEx setParent(IoSessionEx newParent) { return super.setParent(newParent); }
@Override public ResourceAddress getLocalAddress() { return super.getLocalAddress(); }
public void cancelSessionTimeoutCommand() { // Cancel the lifetime enforcement if we have closed already. cancelCommand(sessionTimeout); }
@Override public <T extends Message> IoBufferEx encode(MessageEncoder<T> encoder, T message, IoBufferAllocatorEx<?> allocator, int flags) { return encode("ws", encoder, message, allocator, flags); }
public AbstractWsBridgeSession(IoServiceEx service, IoProcessorEx<S> sIoProcessor, ResourceAddress localAddress, ResourceAddress remoteAddress, IoSessionEx parent, IoBufferAllocatorEx<B> allocator, Direction direction, ResultAwareLoginContext loginContext, List<WebSocketExtension> extensions) { super(service, sIoProcessor, localAddress, remoteAddress, parent, allocator, direction); this.loginContext = loginContext; this.sessionTimeout = new WsSessionTimeoutCommand(this); }
public WsTextMessage(IoBufferEx buf) { super(); setBytes(buf); }