const int KeepSecond = int.MaxValue;//30; public void Tick(IGateServer gateSever) { //这里应该有一个倒计时,发现超过时间的就要让他断线啦 lock (this) { var lst = new List <ulong>(); System.DateTime nowTime = System.DateTime.Now; foreach (var i in mLinkers) { if ((nowTime - i.Value.OffLineKeepTime).Seconds > KeepSecond) { TimeOutDisconnect(gateSever, i.Value); lst.Add(i.Key); } } foreach (var i in lst) { mLinkers.Remove(i); } } }
void TimeOutDisconnect(IGateServer gateSever, ClientLinker linker) { linker.OffLineKeepLinker = false; gateSever.NotifyOtherServers_ClientDisconnect(linker); }