public class HeartBeat extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static HeartBeat |
attachSession(IoSession session,
ConnectModel connectModel)
将心跳绑定到 Session
默认使用 PING, PONG 作为心跳消息
|
static HeartBeat |
attachSession(IoSession session,
ConnectModel connectModel,
String ping,
String pong)
将心跳绑定到 Session
|
static boolean |
beat(IoSession session)
一次心跳动作
|
int |
getFailedCount()
获取连续失败次数
每次成功会被归零
|
byte[] |
getPing()
获取 ping 报文
|
byte[] |
getPong()
获取 pong 报文
|
static void |
interceptHeartBeat(IoSession session,
ByteBufferChannel byteBufferChannel)
截断心跳消息
|
static void |
main(String[] args) |
public byte[] getPing()
public byte[] getPong()
public int getFailedCount()
public static void interceptHeartBeat(IoSession session, ByteBufferChannel byteBufferChannel)
session - 会话对象byteBufferChannel - 保存消息 ByteBufferChannel 对象public static boolean beat(IoSession session)
session - 会话对象public static HeartBeat attachSession(IoSession session, ConnectModel connectModel, String ping, String pong)
session - 会话connectModel - 模式,指定发送第一个 PING 的模式,服务端先发,或者客户端先发ping - ping 消息pong - pong 消息public static HeartBeat attachSession(IoSession session, ConnectModel connectModel)
session - Socket会话connectModel - 模式,指定发送第一个 PING 的模式,服务端先发,或者客户端先发public static void main(String[] args) throws IOException
IOExceptionCopyright © 2017 Voovan. All rights reserved.