//心跳 public void HeartBeat() { //Console.WriteLine("HeartBeat"); long timeNow = TimeUtility.GetTimeStamp(); for (int i = 0; i < conns.Length; i++) { Conn conn = conns[i]; if (conn == null) { continue; } if (!conn.isUse) { continue; } if (timeNow - conn.lastTickTime > HEART_BEAT_TIME) { Console.WriteLine("[心跳引起断开连接] " + conn.GetAdress()); CloseConn(conn); } } }
public static void HeartBeat(Conn conn, Protocol.ProtocolBase proto) { conn.lastTickTime = TimeUtility.GetTimeStamp(); //Console.WriteLine("[HeartBeat]" + conn.GetAdress()); }