private void HeartAsync() { ThreadHelper.Run(() => { try { while (true) { if (this.Connected) { if (Actived.AddMilliseconds(HeartSpan) <= DateTimeHelper.Now) { var sm = new QueueSocketMsg() { BodyLength = 0, Type = (byte)QueueSocketMsgType.Ping }; SendAsync(sm.ToBytes()); } ThreadHelper.Sleep(HeartSpan / 2); } else { ThreadHelper.Sleep(1); } } } catch { } }, true, System.Threading.ThreadPriority.Highest); }
private void SendAsyncBase(QueueSocketMsgType type, byte[] content) { var data = QueueSocketMsg.Parse(content, type).ToBytes(); this.SendAsync(data); Actived = DateTimeHelper.Now; }
private void ReplyBase(IUserToken ut, QueueSocketMsgType type, byte[] content) { var byts = QueueSocketMsg.Parse(content, type).ToBytes(); base.Send(ut, byts); }