org.apache.mina.core.future.DefaultWriteFuture Java Examples
The following examples show how to use
org.apache.mina.core.future.DefaultWriteFuture.
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: SslFilter.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private WriteFuture initiateClosure(NextFilter nextFilter, IoSession session) throws SSLException { SslHandler handler = getSslSessionHandler(session); // if already shut down if (!handler.closeOutbound()) { return DefaultWriteFuture.newNotWrittenFuture(session, new IllegalStateException( "SSL session is shut down already.")); } // there might be data to write out here? WriteFuture future = handler.writeNetBuffer(nextFilter); if (future == null) { future = DefaultWriteFuture.newWrittenFuture(session); } if (handler.isInboundDone()) { handler.destroy(); } if (session.containsAttribute(USE_NOTIFICATION)) { handler.scheduleMessageReceived(nextFilter, SESSION_UNSECURED); } return future; }
Example #2
Source File: NetManager.java From jane with GNU Lesser General Public License v3.0 | 6 votes |
/** * 发送对象的底层入口. 可带监听器,并返回WriteFuture */ public static WriteFuture write(IoSession session, Object obj, IoFutureListener<?> listener) { if (session.isClosing() || obj == null) return null; IoFilterChain ifc = session.getFilterChain(); WriteFuture wf = new DefaultWriteFuture(session); if (listener != null) wf.addListener(listener); DefaultWriteRequest dwr = new DefaultWriteRequest(obj, wf); synchronized (session) { ifc.fireFilterWrite(dwr); } return wf; }
Example #3
Source File: MockProtocolEncoderOutput.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override public WriteFuture flush() { DummySession dummySession = new DummySession(); DefaultWriteFuture writeFuture = new DefaultWriteFuture(dummySession); return writeFuture; }
Example #4
Source File: AbstractProxyLogicHandler.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * Writes data to the proxy server. * * @param nextFilter the next filter * @param data Data buffer to be written. */ protected WriteFuture writeData(final NextFilter nextFilter, final IoBuffer data) { // write net data ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data); LOGGER.debug(" session write: {}", writeBuffer); WriteFuture writeFuture = new DefaultWriteFuture(getSession()); getProxyFilter().writeData(nextFilter, getSession(), new DefaultWriteRequest(writeBuffer, writeFuture), true); return writeFuture; }
Example #5
Source File: NioSession.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
@Override public WriteFuture write(Object message) { if (message == null) throw new IllegalArgumentException("trying to write a null message: not allowed"); // If the session has been closed or is closing, we can't either send a message to the remote side. // We generate a future containing an exception. if (isClosing() || !isConnected()) return DefaultWriteFuture.newNotWrittenFuture(this, new WriteToClosedSessionException(null)); try { if ((message instanceof IoBuffer) && !((IoBuffer)message).hasRemaining()) { // Nothing to write: probably an error in the user code throw new IllegalArgumentException("message is empty, forgot to call flip()?"); } else if (message instanceof FileChannel) { FileChannel fileChannel = (FileChannel)message; message = new DefaultFileRegion(fileChannel, 0, fileChannel.size()); } } catch (IOException e) { ExceptionMonitor.getInstance().exceptionCaught(e); return DefaultWriteFuture.newNotWrittenFuture(this, e); } // Now, we can write the message. WriteFuture writeFuture = new DefaultWriteFuture(this); WriteRequest writeRequest = new DefaultWriteRequest(message, writeFuture); filterChain.fireFilterWrite(writeRequest); return writeFuture; }
Example #6
Source File: SslHandler.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
WriteFuture writeNetBuffer(NextFilter nextFilter, boolean needFuture) throws Exception { // Check if any net data needed to be writen if (outNetBuffer == null || !outNetBuffer.hasRemaining()) return null; // no; bail out // set flag that we are writing encrypted data (used in SSLFilter.filterWrite()) writingEncryptedData = true; // write net data WriteFuture writeFuture = (needFuture ? new DefaultWriteFuture(session) : null); try { IoBuffer writeBuffer = fetchOutNetBuffer(); sslFilter.filterWrite(nextFilter, session, writeFuture != null ? new DefaultWriteRequest(writeBuffer, writeFuture) : writeBuffer); // loop while more writes required to complete handshake while (handshakeStatus == HandshakeStatus.NEED_WRAP && !isInboundDone()) { try { handshake(nextFilter); } catch (SSLException ssle) { SSLException newSsle = new SSLHandshakeException("SSL handshake failed"); newSsle.initCause(ssle); throw newSsle; } IoBuffer currentOutNetBuffer = fetchOutNetBuffer(); if (currentOutNetBuffer != null && currentOutNetBuffer.hasRemaining()) { writeFuture = (needFuture ? new DefaultWriteFuture(session) : null); sslFilter.filterWrite(nextFilter, session, writeFuture != null ? new DefaultWriteRequest(currentOutNetBuffer, writeFuture) : currentOutNetBuffer); } } } finally { writingEncryptedData = false; } return writeFuture; }
Example #7
Source File: SslFilter.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
private WriteFuture initiateClosure(NextFilter nextFilter, IoSession session, boolean needFuture) throws Exception { SslHandler sslHandler = getSslSessionHandler(session); WriteFuture future; // if already shutdown try { synchronized (sslHandler) { if (!sslHandler.closeOutbound()) return DefaultWriteFuture.newNotWrittenFuture(session, new IllegalStateException("SSL session is shutdown already")); // there might be data to write out here? future = sslHandler.writeNetBuffer(nextFilter, needFuture); if (needFuture && future == null) future = DefaultWriteFuture.newWrittenFuture(session); if (sslHandler.isInboundDone()) sslHandler.destroy(); } if (session.containsAttribute(USE_NOTIFICATION)) sslHandler.scheduleMessageReceived(nextFilter, SESSION_UNSECURED); } catch (SSLException se) { sslHandler.release(); throw se; } return future; }
Example #8
Source File: ITCHMulticastUDPSession.java From sailfish-core with Apache License 2.0 | 4 votes |
@Override public WriteFuture flush() { return new DefaultWriteFuture(session); }
Example #9
Source File: TestFastCodec.java From sailfish-core with Apache License 2.0 | 4 votes |
@Override public WriteFuture flush() { return new DefaultWriteFuture(session); }
Example #10
Source File: TestNTGHelper.java From sailfish-core with Apache License 2.0 | 4 votes |
@Override public WriteFuture flush() { DummySession dummySession = new DummySession(); DefaultWriteFuture writeFuture = new DefaultWriteFuture(dummySession); return writeFuture; }