client和server的连接: 叫session
Session State:
- Connected : the session has been created and is available
- Idle : the session hasn't processed any request for at least a period of time (this period is configurable)
- Idle for read : no read has actually been made for a period of time
- Idle for write : no write has actually been made for a period of time
- Idle for both : no read nor write for a period of time
- Closing : the session is being closed (the remaining messages are being flushed, cleaning up is not terminated)
- Closed : The session is now closed, nothing else can be done to revive it.
状态转换图:
Session需要配置的参数:
Many different parameters can be set for a specific session :
- receive buffer size
- sending buffer size
- Idle time
- Write timeOut
Container
在session中,有一个container,可以放置key/value属性(是个map结构);
如果要用自己的container,譬如不用map,或者大尺寸value要放在磁盘上,要能够自己替换这个container
实现这个接口:
public interface IoSessionDataStructureFactory {
/**
* Returns an {@link IoSessionAttributeMap} which is going to be associated
* with the specified <tt>session</tt>. Please note that the returned
* implementation must be thread-safe.
*/
IoSessionAttributeMap getAttributeMap(IoSession session) throws Exception;
}
Filter chain
Handler
分享到:
相关推荐
mina连接,mina心跳连接,mina断线重连。其中客户端可直接用在android上。根据各方参考资料,经过自己的理解弄出来的。CSDN的资源分太难得了。
springboot集成mina做分布式的soket服务,思路:用java线性安全的集合存储mina session到本地服务器;同时用redis等nosql缓存mina session存储服务器的ip,session的id等信息到redis上;应用服务器直接用restful等...
例如,创建Acceptor来监听特定端口,当有新的连接请求时,MINA会自动创建一个Session对象,并调用IoHandler的事件处理方法。 ```java public class SimpleServerHandler implements IoHandler { @Override ...
Mina2.0框架源码剖析 Mina2.0是一个基于Java的网络应用框架,提供了一个简洁、灵活的API,帮助开发者快速构建高性能的网络应用程序。下面是Mina2.0框架源码剖析的相关知识点: 一、Mina2.0框架概述 Mina2.0是一个...
Chapter 4 - Session Chapter 5 - Filters Chapter 6 - Transports Chapter 7 - Handler Part II - MINA Core Chapter 8 - Acceptor Chapter 9 - Connector Chapter 10 - IoBuffer Chapter 11 - Codec Filter ...
Apache Mina是一个高性能的网络应用框架,主要用于简化开发网络服务应用程序。Mina提供了一种抽象层,使得开发者能够专注于业务逻辑,而不是底层的网络通信细节。以下是对Mina服务器核心概念的详细解释: 1. **...
3. `sessionIdle()`:当会话在指定时间内没有读写活动时,此方法会被调用。在示例中,如果会话在10秒内既没有读也没有写操作,服务器会关闭会话。 这个简单的例子展示了Mina2.0如何通过过滤器链、处理器和I/O选择器...
在test3(2)基础上修改MinaClient的session = future.getSession();即可。 (2)如果建立Server的Client离开了,让另一个Client建立Server。 (3)Client给Server发送数据,如果失败,重新发送。 test5:一个...
* Session 是 MINA 中的一个核心组件,负责管理会话信息。 * Session 提供了一个灵活的架构,使得开发者可以轻松地构建高性能的会话管理。 Chapter 5 - Filter(过滤器) 本章节介绍了 Filter 的基本概念和特性。 ...
MINA框架简介 MINA框架是Apache开发的一个网络通信应用框架,主要用于对基于TCP/IP、UDP/IP协议栈的通信框架。MINA框架可以帮助开发者快速开发高性能、高扩展性的网络通信应用。MINA框架提供了事件驱动、异步操作的...
连接建立后,客户端可以通过Session对象进行读写操作。 7. **长连接与短连接**:长连接是指在一次连接建立后,可以反复进行多次数据传输,直到一方主动关闭连接。短连接则是每次通信都创建新的连接,完成后立即关闭...
- **Session(会话)**: Session代表一个客户端连接,包含了连接状态和配置信息。 MINA2通过这些组件提供了一种高效、灵活的网络编程模型,使得开发者可以轻松地构建高性能的网络应用,如聊天服务器、游戏服务器或...
Apache Mina 是一个高性能、轻量级的 Java 框架,专用于开发网络应用程序,特别是基于 TCP/IP 和 UDP/IP 协议的通信。它的设计目标是简化网络通信的复杂性,提供了一种简洁而易于使用的API来处理网络连接、数据传输...
该框架核心包包括 org.apache.mina.core.service, org.apache.mina.core.session, org.apache.mina.core.polling 以及 org.apache.mina.transport.socket。 Mina2 框架的核心组件之一是 IoService 接口,它是所有 ...
import org.apache.mina.core.session.IdleStatus; import org.apache.mina.filter.codec.ProtocolCodecFilter; import org.apache.mina.filter.logging.LoggingFilter; import org.apache.mina.transport.socket....
如何将session 值保持在redis缓存中。
AndroidPN的源代码结构包含了服务器端和客户端的相关模块,例如,`org.androidpn.server.xmpp.net.Connection`类代表服务器的XMPP连接,而`org.androidpn.server.xmpp.session.SessionManager`负责会话管理。...