@Override
    public void registerConnectionClosedEventListener(final ConnectionClosedEventListener listener) {
        this.rpcServer.addConnectionEventProcessor(ConnectionEventType.CLOSE, (remoteAddress, conn) -> {
            final Connection proxyConn = conn == null ? null : new Connection() {

                @Override
                public Object getAttribute(final String key) {
                    return conn.getAttribute(key);
                }

                @Override
                public Object setAttributeIfAbsent(final String key, final Object value) {
                    return conn.setAttributeIfAbsent(key, value);
                }

                @Override
                public void setAttribute(final String key, final Object value) {
                    conn.setAttribute(key, value);
                }

                @Override
                public void close() {
                    conn.close();
                }
            };

            listener.onClosed(remoteAddress, proxyConn);
        });
    }
Bolt RPC server impl.

@author jiachun.fjc
jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/impl/BoltRpcServer.java