org.xnio.ChannelListener Java Examples
The following examples show how to use
org.xnio.ChannelListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSServer.java From greycat with Apache License 2.0 | 6 votes |
@Override public final void on(final Buffer result) { //broadcast to anyone... WebSocketChannel[] others = peers.toArray(new WebSocketChannel[peers.size()]); Buffer notificationBuffer = new HeapBuffer(); notificationBuffer.write(StorageMessageType.NOTIFY_UPDATE); notificationBuffer.write(Constants.BUFFER_SEP); notificationBuffer.writeAll(result.data()); byte[] notificationMsg = notificationBuffer.data(); notificationBuffer.free(); for (int i = 0; i < others.length; i++) { PeerInternalListener listener = (PeerInternalListener) ((ChannelListener.SimpleSetter) others[i].getReceiveSetter()).get(); //locally invalidate cache listener.graph.remoteNotify(result); //notify to connected peer send_flat_resp(notificationMsg, others[i]); } }
Example #2
Source File: ManagementHttpServer.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void start() { try { OptionMap.Builder serverOptionsBuilder = OptionMap.builder() .set(Options.TCP_NODELAY, true) .set(Options.REUSE_ADDRESSES, true); ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener); if (httpAddress != null) { normalServer = worker.createStreamConnectionServer(httpAddress, acceptListener, serverOptionsBuilder.getMap()); normalServer.resumeAccepts(); } if (secureAddress != null) { if (sslClientAuthMode != null) { serverOptionsBuilder.set(SSL_CLIENT_AUTH_MODE, sslClientAuthMode); } OptionMap secureOptions = serverOptionsBuilder.getMap(); XnioSsl xnioSsl = new UndertowXnioSsl(worker.getXnio(), secureOptions, sslContext); secureServer = xnioSsl.createSslConnectionServer(worker, secureAddress, acceptListener, secureOptions); secureServer.resumeAccepts(); } } catch (IOException e) { throw new RuntimeException(e); } }
Example #3
Source File: HttpClientConnection.java From lams with GNU General Public License v2.0 | 6 votes |
protected void doHttp2Upgrade() { try { StreamConnection connectedStreamChannel = this.performUpgrade(); Http2Channel http2Channel = new Http2Channel(connectedStreamChannel, null, bufferPool, null, true, true, options); Http2ClientConnection http2ClientConnection = new Http2ClientConnection(http2Channel, currentRequest.getResponseCallback(), currentRequest.getRequest(), currentRequest.getRequest().getRequestHeaders().getFirst(Headers.HOST), clientStatistics, false); http2ClientConnection.getCloseSetter().set(new ChannelListener<ClientConnection>() { @Override public void handleEvent(ClientConnection channel) { ChannelListeners.invokeChannelListener(HttpClientConnection.this, HttpClientConnection.this.closeSetter.get()); } }); http2Delegate = http2ClientConnection; connectedStreamChannel.getSourceChannel().wakeupReads(); //make sure the read listener is immediately invoked, as it may not happen if data is pushed back currentRequest = null; pendingResponse = null; } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); safeClose(this); } }
Example #4
Source File: AjpClientProvider.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap options) { ChannelListener<StreamConnection> openListener = new ChannelListener<StreamConnection>() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, uri, ssl, bufferPool, options); } }; IoFuture.Notifier<StreamConnection, Object> notifier = new IoFuture.Notifier<StreamConnection, Object>() { @Override public void notify(IoFuture<? extends StreamConnection> ioFuture, Object o) { if (ioFuture.getStatus() == IoFuture.Status.FAILED) { listener.failed(ioFuture.getException()); } } }; if(bindAddress == null) { worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null); } else { worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null); } }
Example #5
Source File: AjpClientProvider.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress,final URI uri, final XnioIoThread ioThread, final XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap options) { ChannelListener<StreamConnection> openListener = new ChannelListener<StreamConnection>() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, uri, ssl, bufferPool, options); } }; IoFuture.Notifier<StreamConnection, Object> notifier = new IoFuture.Notifier<StreamConnection, Object>() { @Override public void notify(IoFuture<? extends StreamConnection> ioFuture, Object o) { if (ioFuture.getStatus() == IoFuture.Status.FAILED) { listener.failed(ioFuture.getException()); } } }; if(bindAddress == null) { ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null); } else { ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null); } }
Example #6
Source File: ServerSentEventConnection.java From lams with GNU General Public License v2.0 | 6 votes |
public ServerSentEventConnection(HttpServerExchange exchange, StreamSinkChannel sink) { this.exchange = exchange; this.sink = sink; this.sink.getCloseSetter().set(new ChannelListener<StreamSinkChannel>() { @Override public void handleEvent(StreamSinkChannel channel) { if(timerKey != null) { timerKey.remove(); } for (ChannelListener<ServerSentEventConnection> listener : closeTasks) { ChannelListeners.invokeChannelListener(ServerSentEventConnection.this, listener); } IoUtils.safeClose(ServerSentEventConnection.this); } }); this.sink.getWriteSetter().set(writeListener); }
Example #7
Source File: ChannelUpgradeHandler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Remove a protocol from this handler. * * @param productString the product string to match * @param openListener The open listener */ public synchronized void removeProtocol(String productString, ChannelListener<? super StreamConnection> openListener) { List<Holder> holders = handlers.get(productString); if (holders == null) { return; } Iterator<Holder> it = holders.iterator(); while (it.hasNext()) { Holder holder = it.next(); if (holder.channelListener == openListener) { holders.remove(holder); break; } } if (holders.isEmpty()) { handlers.remove(productString); } }
Example #8
Source File: Http2Channel.java From lams with GNU General Public License v2.0 | 6 votes |
@Override protected void closeSubChannels() { for (Map.Entry<Integer, StreamHolder> e : currentStreams.entrySet()) { StreamHolder holder = e.getValue(); AbstractHttp2StreamSourceChannel receiver = holder.sourceChannel; if(receiver != null) { receiver.markStreamBroken(); } Http2StreamSinkChannel sink = holder.sinkChannel; if(sink != null) { if (sink.isWritesShutdown()) { ChannelListeners.invokeChannelListener(sink.getIoThread(), sink, ((ChannelListener.SimpleSetter) sink.getWriteSetter()).get()); } IoUtils.safeClose(sink); } } }
Example #9
Source File: MultiAppProxyClient.java From bouncr with Eclipse Public License 1.0 | 6 votes |
@Override public void completed(final ClientConnection connection) { final ServerConnection serverConnection = exchange.getConnection(); //we attach to the connection so it can be re-used if (connectionCache) { serverConnection.putAttachment(clientAttachmentKey, connection); } serverConnection.addCloseListener(serverConnection1 -> IoUtils.safeClose(connection)); connection.getCloseSetter().set((ChannelListener<Channel>) channel -> serverConnection.removeAttachment(clientAttachmentKey)); exchange.setRelativePath("/"); Realm realm = realmCache.matches(exchange.getRequestPath()); Application application = realmCache.getApplication(realm); String path = exchange.getRequestURI(); if (path.startsWith(application.getVirtualPath())) { String passTo = calculatePathTo(path, application); exchange.setRequestPath(passTo); exchange.setRequestURI(passTo); } callback.completed(exchange, new ProxyConnection(connection, "/")); }
Example #10
Source File: WebSocketChannel.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a new {@link WebSocketChannel} * 8 * * @param connectedStreamChannel The {@link org.xnio.channels.ConnectedStreamChannel} over which the WebSocket Frames should get send and received. * Be aware that it already must be "upgraded". * @param bufferPool The {@link org.xnio.Pool} which will be used to acquire {@link java.nio.ByteBuffer}'s from. * @param version The {@link WebSocketVersion} of the {@link WebSocketChannel} * @param wsUrl The url for which the channel was created. * @param client * @param peerConnections The concurrent set that is used to track open connections associtated with an endpoint */ protected WebSocketChannel(final StreamConnection connectedStreamChannel, ByteBufferPool bufferPool, WebSocketVersion version, String wsUrl, String subProtocol, final boolean client, boolean extensionsSupported, final ExtensionFunction extensionFunction, Set<WebSocketChannel> peerConnections, OptionMap options) { super(connectedStreamChannel, bufferPool, new WebSocketFramePriority(), null, options); this.client = client; this.version = version; this.wsUrl = wsUrl; this.extensionsSupported = extensionsSupported; this.extensionFunction = extensionFunction; this.hasReservedOpCode = extensionFunction.hasExtensionOpCode(); this.subProtocol = subProtocol; this.peerConnections = peerConnections; addCloseTask(new ChannelListener<WebSocketChannel>() { @Override public void handleEvent(WebSocketChannel channel) { extensionFunction.dispose(); WebSocketChannel.this.peerConnections.remove(WebSocketChannel.this); } }); }
Example #11
Source File: WebSocketTtyConnection.java From aesh-readline with Apache License 2.0 | 6 votes |
private void registerWebSocketChannelListener(WebSocketChannel webSocketChannel) { ChannelListener<WebSocketChannel> listener = new AbstractReceiveListener() { @Override protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException { log.log(Level.FINE, "Server received full binary message"); Pooled<ByteBuffer[]> pulledData = message.getData(); try { ByteBuffer[] resource = pulledData.getResource(); ByteBuffer byteBuffer = WebSockets.mergeBuffers(resource); String msg = new String(byteBuffer.array()); log.log(Level.FINE, "Sending message to decoder: "+ msg); writeToDecoder(msg); } finally { pulledData.discard(); } } }; webSocketChannel.getReceiveSetter().set(listener); }
Example #12
Source File: WebSocketTtyConnection.java From termd with Apache License 2.0 | 6 votes |
private void registerWebSocketChannelListener(WebSocketChannel webSocketChannel) { ChannelListener<WebSocketChannel> listener = new AbstractReceiveListener() { @Override protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException { log.trace("Server received full binary message"); Pooled<ByteBuffer[]> pulledData = message.getData(); try { ByteBuffer[] resource = pulledData.getResource(); ByteBuffer byteBuffer = WebSockets.mergeBuffers(resource); String msg = new String(byteBuffer.array()); log.trace("Sending message to decoder: {}", msg); writeToDecoder(msg); } finally { pulledData.discard(); } } }; webSocketChannel.getReceiveSetter().set(listener); }
Example #13
Source File: Light4jHttpClientProvider.java From light-4j with Apache License 2.0 | 5 votes |
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final ByteBufferPool bufferPool, final OptionMap options, final URI uri) { return new ChannelListener<StreamConnection>() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, bufferPool, options, uri); } }; }
Example #14
Source File: AbstractFramedChannel.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void handleEvent(final StreamSourceChannel channel) { //clear the task queue before reading while (!taskRunQueue.isEmpty()) { taskRunQueue.poll().run(); } final R receiver = AbstractFramedChannel.this.receiver; if ((readChannelDone || receivesSuspended) && receiver == null) { channel.suspendReads(); return; } else { ChannelListener listener = receiveSetter.get(); if(listener == null) { listener = DRAIN_LISTENER; } UndertowLogger.REQUEST_IO_LOGGER.tracef("Invoking receive listener", receiver); ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener); } if (readData != null && !readData.isFreed() && channel.isOpen()) { try { runInIoThread(new Runnable() { @Override public void run() { ChannelListeners.invokeChannelListener(channel, FrameReadListener.this); } }); } catch (RejectedExecutionException e) { IoUtils.safeClose(AbstractFramedChannel.this); } } }
Example #15
Source File: AbstractFramedChannel.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new {@link io.undertow.server.protocol.framed.AbstractFramedChannel} * 8 * @param connectedStreamChannel The {@link org.xnio.channels.ConnectedStreamChannel} over which the Frames should get send and received. * Be aware that it already must be "upgraded". * @param bufferPool The {@link ByteBufferPool} which will be used to acquire {@link ByteBuffer}'s from. * @param framePriority * @param settings The settings */ protected AbstractFramedChannel(final StreamConnection connectedStreamChannel, ByteBufferPool bufferPool, FramePriority<C, R, S> framePriority, final PooledByteBuffer readData, OptionMap settings) { this.framePriority = framePriority; this.maxQueuedBuffers = settings.get(UndertowOptions.MAX_QUEUED_READ_BUFFERS, 10); this.settings = settings; if (readData != null) { if(readData.getBuffer().hasRemaining()) { this.readData = new ReferenceCountedPooled(readData, 1); } else { readData.close(); } } if(bufferPool == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("bufferPool"); } if(connectedStreamChannel == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("connectedStreamChannel"); } IdleTimeoutConduit idle = createIdleTimeoutChannel(connectedStreamChannel); connectedStreamChannel.getSourceChannel().setConduit(idle); connectedStreamChannel.getSinkChannel().setConduit(idle); this.idleTimeoutConduit = idle; this.channel = connectedStreamChannel; this.bufferPool = bufferPool; closeSetter = new ChannelListener.SimpleSetter<>(); receiveSetter = new ChannelListener.SimpleSetter<>(); channel.getSourceChannel().getReadSetter().set(null); channel.getSourceChannel().suspendReads(); channel.getSourceChannel().getReadSetter().set(new FrameReadListener()); connectedStreamChannel.getSinkChannel().getWriteSetter().set(new FrameWriteListener()); FrameCloseListener closeListener = new FrameCloseListener(); connectedStreamChannel.getSinkChannel().getCloseSetter().set(closeListener); connectedStreamChannel.getSourceChannel().getCloseSetter().set(closeListener); }
Example #16
Source File: AbstractFramedStreamSourceChannel.java From lams with GNU General Public License v2.0 | 5 votes |
public void addCloseTask(ChannelListener<R> channelListener) { if(closeListeners == null) { closeListeners = new ChannelListener[]{channelListener}; } else { ChannelListener[] old = closeListeners; closeListeners = new ChannelListener[old.length + 1]; System.arraycopy(old, 0, closeListeners, 0, old.length); closeListeners[old.length] = channelListener; } }
Example #17
Source File: ProxyConnectionPool.java From lams with GNU General Public License v2.0 | 5 votes |
private void openConnection(final HttpServerExchange exchange, final ProxyCallback<ProxyConnection> callback, final HostThreadData data, final boolean exclusive) { if (!exclusive) { data.connections++; } client.connect(new ClientCallback<ClientConnection>() { @Override public void completed(final ClientConnection result) { openConnections.incrementAndGet(); final ConnectionHolder connectionHolder = new ConnectionHolder(result); if (!exclusive) { result.getCloseSetter().set(new ChannelListener<ClientConnection>() { @Override public void handleEvent(ClientConnection channel) { handleClosedConnection(data, connectionHolder); } }); } connectionReady(connectionHolder, callback, exchange, exclusive); } @Override public void failed(IOException e) { if (!exclusive) { data.connections--; } UndertowLogger.REQUEST_LOGGER.debug("Failed to connect", e); if (!connectionPoolManager.handleError()) { redistributeQueued(getData()); scheduleFailedHostRetry(exchange); } callback.failed(exchange); } }, bindAddress, getUri(), exchange.getIoThread(), ssl, exchange.getConnection().getByteBufferPool(), options); }
Example #18
Source File: AbstractXnioSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 5 votes |
private void setOpWrite() { ConduitStreamSinkChannel sink = connection().getSinkChannel(); if (!sink.isWriteResumed()) { ChannelListener<ConduitStreamSinkChannel> writeListener = this.writeListener; if (writeListener == null) { writeListener = this.writeListener = new WriteListener(); } sink.getWriteSetter().set(writeListener); sink.resumeWrites(); } }
Example #19
Source File: Transfer.java From lams with GNU General Public License v2.0 | 5 votes |
private static <I extends StreamSourceChannel, O extends StreamSinkChannel> void done(I source, O sink, ChannelListener<? super I> sourceListener, ChannelListener<? super O> sinkListener) { Channels.setReadListener(source, sourceListener); if (sourceListener == null) { source.suspendReads(); } else { source.wakeupReads(); } Channels.setWriteListener(sink, sinkListener); if (sinkListener == null) { sink.suspendWrites(); } else { sink.wakeupWrites(); } }
Example #20
Source File: Transfer.java From lams with GNU General Public License v2.0 | 5 votes |
TransferListener(ByteBufferPool pool, final PooledByteBuffer pooledBuffer, final I source, final O sink, final ChannelListener<? super I> sourceListener, final ChannelListener<? super O> sinkListener, final ChannelExceptionHandler<? super O> writeExceptionHandler, final ChannelExceptionHandler<? super I> readExceptionHandler, boolean sourceDone) { this.pool = pool; this.pooledBuffer = pooledBuffer; this.source = source; this.sink = sink; this.sourceListener = sourceListener; this.sinkListener = sinkListener; this.writeExceptionHandler = writeExceptionHandler; this.readExceptionHandler = readExceptionHandler; this.sourceDone = sourceDone; }
Example #21
Source File: DetachableStreamSinkChannel.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public ChannelListener.Setter<? extends StreamSinkChannel> getWriteSetter() { if (writeSetter == null) { writeSetter = new ChannelListener.SimpleSetter<>(); if (!isFinished()) { if(delegate instanceof ConduitStreamSinkChannel) { ((ConduitStreamSinkChannel) delegate).setWriteListener(new SetterDelegatingListener((ChannelListener.SimpleSetter)writeSetter, this)); } else { delegate.getWriteSetter().set(new SetterDelegatingListener((ChannelListener.SimpleSetter)writeSetter, this)); } } } return writeSetter; }
Example #22
Source File: AbstractFramedStreamSourceChannel.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void close() { if(anyAreSet(state, STATE_CLOSED)) { return; } synchronized (lock) { state |= STATE_CLOSED; if (allAreClear(state, STATE_DONE | STATE_LAST_FRAME)) { state |= STATE_STREAM_BROKEN; channelForciblyClosed(); } if (data != null) { data.close(); data = null; } while (!pendingFrameData.isEmpty()) { pendingFrameData.poll().frameData.close(); } ChannelListeners.invokeChannelListener(this, (ChannelListener<? super AbstractFramedStreamSourceChannel<C, R, S>>) closeSetter.get()); if (closeListeners != null) { for (int i = 0; i < closeListeners.length; ++i) { closeListeners[i].handleEvent(this); } } } }
Example #23
Source File: AbstractFramedStreamSinkChannel.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void close() throws IOException { if(fullyFlushed || anyAreSet(state, STATE_CLOSED)) { return; } try { synchronized (lock) { state |= STATE_CLOSED; } if(writeBuffer != null) { writeBuffer.close(); writeBuffer = null; } if(body != null) { body.close(); body = null; } if (header != null && header.getByteBuffer() != null) { header.getByteBuffer().close(); header = null; } channelForciblyClosed(); //we need to wake up/invoke the write listener if (isWriteResumed()) { ChannelListeners.invokeChannelListener(getIoThread(), this, (ChannelListener) getWriteListener()); } wakeupWrites(); } finally { wakeupWaiters(); } }
Example #24
Source File: HttpReadListener.java From lams with GNU General Public License v2.0 | 5 votes |
private void handleHttp2PriorKnowledge(final StreamConnection connection, final HttpServerConnection serverConnection, PooledByteBuffer readData) throws IOException { final ConduitStreamSourceChannel request = connection.getSourceChannel(); byte[] data = new byte[PRI_EXPECTED.length]; final ByteBuffer buffer = ByteBuffer.wrap(data); if(readData.getBuffer().hasRemaining()) { while (readData.getBuffer().hasRemaining() && buffer.hasRemaining()) { buffer.put(readData.getBuffer().get()); } } final PooledByteBuffer extraData; if(readData.getBuffer().hasRemaining()) { extraData = readData; } else { readData.close(); extraData = null; } if(!doHttp2PriRead(connection, buffer, serverConnection, extraData)) { request.getReadSetter().set(new ChannelListener<StreamSourceChannel>() { @Override public void handleEvent(StreamSourceChannel channel) { try { doHttp2PriRead(connection, buffer, serverConnection, extraData); } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(connection); } catch (Throwable t) { UndertowLogger.REQUEST_IO_LOGGER.handleUnexpectedFailure(t); IoUtils.safeClose(connection); } } }); request.resumeReads(); } }
Example #25
Source File: Http2ClientProvider.java From lams with GNU General Public License v2.0 | 5 votes |
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final URI uri, final XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap options) { return new ChannelListener<StreamConnection>() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, uri, bufferPool, options); } }; }
Example #26
Source File: HttpClientProvider.java From lams with GNU General Public License v2.0 | 5 votes |
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final ByteBufferPool bufferPool, final OptionMap options, final URI uri) { return new ChannelListener<StreamConnection>() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, bufferPool, options, uri); } }; }
Example #27
Source File: DetachableStreamSinkChannel.java From lams with GNU General Public License v2.0 | 5 votes |
public void handleEvent(final StreamSinkChannel channel) { ChannelListener<? super StreamSinkChannel> channelListener = setter.get(); if(channelListener != null) { ChannelListeners.invokeChannelListener(this.channel, channelListener); } else { UndertowLogger.REQUEST_LOGGER.debugf("suspending writes on %s to prevent listener runaway", channel); channel.suspendWrites(); } }
Example #28
Source File: Http2ClientProvider.java From lams with GNU General Public License v2.0 | 5 votes |
public static ALPNClientSelector.ALPNProtocol alpnProtocol(final ClientCallback<ClientConnection> listener, URI uri, ByteBufferPool bufferPool, OptionMap options) { return new ALPNClientSelector.ALPNProtocol(new ChannelListener<SslConnection>() { @Override public void handleEvent(SslConnection connection) { listener.completed(createHttp2Channel(connection, bufferPool, options, uri.getHost())); } }, HTTP2); }
Example #29
Source File: Http2ClientConnection.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void handleEvent(Http2Channel channel) { ChannelListeners.invokeChannelListener(Http2ClientConnection.this, closeSetter.get()); for (ChannelListener<ClientConnection> listener : closeListeners) { listener.handleEvent(Http2ClientConnection.this); } for (Map.Entry<Integer, Http2ClientExchange> entry : currentExchanges.entrySet()) { entry.getValue().failed(new ClosedChannelException()); } currentExchanges.clear(); }
Example #30
Source File: DetachableStreamSourceChannel.java From lams with GNU General Public License v2.0 | 5 votes |
public ChannelListener.Setter<? extends StreamSourceChannel> getCloseSetter() { if (closeSetter == null) { closeSetter = new ChannelListener.SimpleSetter<>(); if (!isFinished()) { if(delegate instanceof ConduitStreamSourceChannel) { ((ConduitStreamSourceChannel)delegate).setCloseListener(ChannelListeners.delegatingChannelListener(this, closeSetter)); } else { delegate.getCloseSetter().set(ChannelListeners.delegatingChannelListener(this, closeSetter)); } } } return closeSetter; }