本文整理了Java中org.apache.mina.transport.socket.SocketSessionConfig.setKeepAlive()
方法的一些代码示例,展示了SocketSessionConfig.setKeepAlive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketSessionConfig.setKeepAlive()
方法的具体详情如下:
包路径:org.apache.mina.transport.socket.SocketSessionConfig
类名称:SocketSessionConfig
方法名:setKeepAlive
暂无
代码示例来源:origin: Red5/red5-server
sessionConf.setKeepAlive(keepAlive);
代码示例来源:origin: kingston-csj/jforgame
private SocketSessionConfig getSessionConfig() {
SocketSessionConfig config = new DefaultSocketSessionConfig();
config.setKeepAlive(true);
config.setReuseAddress(true);
return config;
}
代码示例来源:origin: youtongluan/sumk
if (SocketSessionConfig.class.isInstance(acceptor.getSessionConfig())) {
SocketSessionConfig conf = (SocketSessionConfig) acceptor.getSessionConfig();
conf.setKeepAlive(true);
conf.setReceiveBufferSize(100);
conf.setSendBufferSize(8192);
代码示例来源:origin: sics-sse/moped
if (!server.equals("none")) {
NioSocketConnector connector = new NioSocketConnector();
connector.getSessionConfig().setKeepAlive(true);
代码示例来源:origin: quickfix-j/quickfixj
SocketSessionConfig socketSessionConfig = (SocketSessionConfig) sessionConfig;
if (keepAlive != null) {
socketSessionConfig.setKeepAlive(keepAlive);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.quickfix
SocketSessionConfig socketSessionConfig = (SocketSessionConfig) sessionConfig;
if (keepAlive != null) {
socketSessionConfig.setKeepAlive(keepAlive);
代码示例来源:origin: org.quickfixj/quickfixj-all
SocketSessionConfig socketSessionConfig = (SocketSessionConfig) sessionConfig;
if (keepAlive != null) {
socketSessionConfig.setKeepAlive(keepAlive);
代码示例来源:origin: com.madgag/mini-git-server-sshd
@Override
protected ServerSession createSession(final IoSession io)
throws Exception {
if (io.getConfig() instanceof SocketSessionConfig) {
final SocketSessionConfig c = (SocketSessionConfig) io.getConfig();
c.setKeepAlive(keepAlive);
}
final ServerSession s = (ServerSession) super.createSession(io);
final int id = idGenerator.next();
final SocketAddress peer = io.getRemoteAddress();
final SshSession sd = new SshSession(id, peer);
s.setAttribute(SshSession.KEY, sd);
// Log a session close without authentication as a failure.
//
io.getCloseFuture().addListener(new IoFutureListener<IoFuture>() {
@Override
public void operationComplete(IoFuture future) {
if (sd.isAuthenticationError()) {
sshLog.onAuthFail(sd);
}
}
});
return s;
}
});
代码示例来源:origin: rtyley/mini-git-server
@Override
protected ServerSession createSession(final IoSession io)
throws Exception {
if (io.getConfig() instanceof SocketSessionConfig) {
final SocketSessionConfig c = (SocketSessionConfig) io.getConfig();
c.setKeepAlive(keepAlive);
}
final ServerSession s = (ServerSession) super.createSession(io);
final int id = idGenerator.next();
final SocketAddress peer = io.getRemoteAddress();
final SshSession sd = new SshSession(id, peer);
s.setAttribute(SshSession.KEY, sd);
// Log a session close without authentication as a failure.
//
io.getCloseFuture().addListener(new IoFutureListener<IoFuture>() {
@Override
public void operationComplete(IoFuture future) {
if (sd.isAuthenticationError()) {
sshLog.onAuthFail(sd);
}
}
});
return s;
}
});
代码示例来源:origin: r17171709/android_demo
private PushManager() {
connector=new NioSocketConnector();
connector.setConnectTimeoutMillis(Params.CONNECT_TIMEOUT);
//为接收器设置管理服务
connector.setHandler(new ClientSessionHandler());
//设置过滤器(使用Mina提供的文本换行符编解码器)
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"), LineDelimiter.WINDOWS.getValue(),LineDelimiter.WINDOWS.getValue())));
//读写通道5秒内无操作进入空闲状态
connector.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, Params.REQUEST_TIMEOUT);
//设置读取数据的缓冲区大小
connector.getSessionConfig().setReadBufferSize(2048);
//设置心跳
KeepAliveMessageFactory heartBeatFactory = new ClientKeepAliveMessageFactoryImp();
KeepAliveRequestTimeoutHandler heartBeatHandler = new ClientKeepAliveMessageTimeoutFactoryImp();
KeepAliveFilter heartBeat = new KeepAliveFilter(heartBeatFactory, IdleStatus.BOTH_IDLE, heartBeatHandler);
//是否回发
heartBeat.setForwardEvent(true);
//心跳发送频率
heartBeat.setRequestInterval(Params.REQUEST_INTERVAL);
connector.getSessionConfig().setKeepAlive(true);
connector.getFilterChain().addLast("keepalive", heartBeat);
}
代码示例来源:origin: org.apache.sshd/sshd-mina
if (boolVal != null) {
try {
config.setKeepAlive(boolVal);
} catch (RuntimeIoException t) {
handleConfigurationError(config, FactoryManager.SOCKET_KEEPALIVE, boolVal, t);
内容来源于网络,如有侵权,请联系作者删除!