Search in sources :

Example 1 with ProtocolEncoder

use of com.generallycloud.baseio.protocol.ProtocolEncoder in project baseio by generallycloud.

the class AbstractSocketChannel method flush.

@Override
public void flush(ChannelFuture future) {
    if (future == null || future.flushed()) {
        return;
    }
    future.flush();
    if (!isOpened()) {
        exceptionCaught(getContext().getIoEventHandleAdaptor(), future, new ClosedChannelException(toString()));
        return;
    }
    try {
        ProtocolEncoder encoder = getProtocolEncoder();
        // 请勿将future.flush()移到getProtocolEncoder()之前,
        // 有些情况下如协议切换的时候可能需要将此future使用
        // 切换前的协议flush
        encoder.encode(this, future);
        doFlush(future);
    } catch (Exception e) {
        exceptionCaught(getContext().getIoEventHandleAdaptor(), future, e);
    }
}
Also used : ClosedChannelException(com.generallycloud.baseio.ClosedChannelException) ProtocolEncoder(com.generallycloud.baseio.protocol.ProtocolEncoder) ClosedChannelException(com.generallycloud.baseio.ClosedChannelException) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException)

Aggregations

ClosedChannelException (com.generallycloud.baseio.ClosedChannelException)1 ProtocolEncoder (com.generallycloud.baseio.protocol.ProtocolEncoder)1 IOException (java.io.IOException)1 SSLException (javax.net.ssl.SSLException)1