/// <summary> /// 发送缓存中的消息 /// </summary> /// <param name="kcp">kcp封包器</param> /// <param name="time">时间</param> public void SendAll(Kcp kcp, Int16 time) { int c = queue.Count; for (int i = 0; i < c; i++) { var l = queue[i]; if (l != null) { kcp.SendMsg(l, time); } } }
/// <summary> /// 发送缓存中的消息,如果没有则发送一条外部消息,防止超时 /// </summary> /// <param name="soc">socket服务</param> /// <param name="kcp">kcp封包器</param> /// <param name="time">时间</param> /// <param name="heart">心跳包</param> public void SendAll(Socket soc, Kcp kcp, Int16 time, byte[] heart) { int c = queue.Count; for (int i = 0; i < c; i++) { var l = queue[i]; if (l != null) { if (kcp.SendMsg(l, time) == 0) { soc.SendTo(heart, l.endpPoint); } } } }