zoukankan      html  css  js  c++  java
  • Apache MINA 框架之默认session管理类实现

    DefaultSocketSessionConfig 类

    extends AbstractSocketSessionConfig extends AbstractIoSessionConfig

    implements SocketSessionConfig,IoSessionConfig

    protected IoService parent;
    private boolean defaultReuseAddress;
    private boolean reuseAddress;
    //接受数据缓冲区大小
     private int receiveBufferSize = -1;
    //发送数据缓冲区大小
     private int sendBufferSize = -1;
    
     private int trafficClass = 0private boolean keepAlive = false;
     private boolean oobInline = false;
     private int soLinger = -1;
     private boolean tcpNoDelay = false;
     public void init(IoService parent) {
            this.parent = parent;
    
            if (parent instanceof SocketAcceptor) {
                defaultReuseAddress = true;
            } else {
                defaultReuseAddress = false;
            }
    
            reuseAddress = defaultReuseAddress;
        }

    doSetAll方法

     protected final void doSetAll(IoSessionConfig config) {
            if (!(config instanceof SocketSessionConfig)) {
                return;
            }
    
            if (config instanceof AbstractSocketSessionConfig) {
                // Minimize unnecessary system calls by checking all 'propertyChanged' properties.
                AbstractSocketSessionConfig cfg = (AbstractSocketSessionConfig) config;
                if (cfg.isKeepAliveChanged()) {
                    setKeepAlive(cfg.isKeepAlive());
                }
                if (cfg.isOobInlineChanged()) {
                    setOobInline(cfg.isOobInline());
                }
                if (cfg.isReceiveBufferSizeChanged()) {
                    setReceiveBufferSize(cfg.getReceiveBufferSize());
                }
                if (cfg.isReuseAddressChanged()) {
                    setReuseAddress(cfg.isReuseAddress());
                }
                if (cfg.isSendBufferSizeChanged()) {
                    setSendBufferSize(cfg.getSendBufferSize());
                }
                if (cfg.isSoLingerChanged()) {
                    setSoLinger(cfg.getSoLinger());
                }
                if (cfg.isTcpNoDelayChanged()) {
                    setTcpNoDelay(cfg.isTcpNoDelay());
                }
                if (cfg.isTrafficClassChanged() && getTrafficClass() != cfg.getTrafficClass()) {
                    setTrafficClass(cfg.getTrafficClass());
                }
            } else {
                SocketSessionConfig cfg = (SocketSessionConfig) config;
                setKeepAlive(cfg.isKeepAlive());
                setOobInline(cfg.isOobInline());
                setReceiveBufferSize(cfg.getReceiveBufferSize());
                setReuseAddress(cfg.isReuseAddress());
                setSendBufferSize(cfg.getSendBufferSize());
                setSoLinger(cfg.getSoLinger());
                setTcpNoDelay(cfg.isTcpNoDelay());
                if (getTrafficClass() != cfg.getTrafficClass()) {
                    setTrafficClass(cfg.getTrafficClass());
                }
            }
    }
  • 相关阅读:
    测测两人的关系.一个小程序,根据用户输入的名字得到笔画数!
    手把手教你做下拉菜单篇
    防止网页内容被复制的最佳方法!
    陈寿福被抓所思二三事!
    测测两人的关系.一个小程序,根据用户输入的名字得到笔画数!
    树状数组
    scanf和cin
    二分答案
    赛后总结
    更新ssl证书后 file_get_contents()方法失效
  • 原文地址:https://www.cnblogs.com/quyongjin/p/3186741.html
Copyright © 2011-2022 走看看