public override void Update() { this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.Recv(); this.CheckWaitTimeout(); this.TimerOut(); foreach (long id in updateChannels) { KChannel kChannel = this.GetKChannel(id); if (kChannel == null) { continue; } if (kChannel.Id == 0) { continue; } kChannel.Update(); } this.updateChannels.Clear(); while (true) { if (this.removedChannels.Count <= 0) { break; } long id = this.removedChannels.Dequeue(); this.localConnChannels.Remove(id); } }
public override void Update() { this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.Recv(); foreach (var kv in this.localConnChannels) { kv.Value.Update(); } while (this.removedChannels.Count > 0) { long id = this.removedChannels.Dequeue(); KChannel channel; if (!this.localConnChannels.TryGetValue(id, out channel)) { continue; } this.localConnChannels.Remove(id); channel.Dispose(); } if (CheckHearBeat && timeHearBeat.IsPassSet()) { foreach (KChannel channel in localConnChannels.Values) { if (channel.CheckHearBeat()) { channel.OnError(ErrorCode.ERR_KcpChannelTimeout); Remove(channel.Id); } } } }
public override void Update() { this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.Recv(); this.TimerOut(); foreach (long id in updateChannels) { KChannel kChannel = this.GetKChannel(id); if (kChannel == null) { continue; } if (kChannel.Id == 0) { continue; } kChannel.Update(); } this.updateChannels.Clear(); while (this.removedChannels.Count > 0) { long id = this.removedChannels.Dequeue(); KChannel channel; if (!this.localConnChannels.TryGetValue(id, out channel)) { continue; } this.localConnChannels.Remove(id); channel.Dispose(); } }
// 计算到期需要update的channel private void TimerOut() { if (this.timerId.Count == 0) { return; } this.TimeNow = (uint)TimeHelper.ClientNow(); timeOutId.Clear(); while (this.timerId.Count > 0) { long k = this.timerId.FirstKey(); if (k > this.TimeNow) { break; } foreach (long ll in this.timerId[k]) { this.timeOutId.Add(ll); } this.timerId.Remove(k); } foreach (long k in this.timeOutId) { this.updateChannels.Add(k); } }
public override void Update() { this.TimeNow = (uint)TimeHelper.ClientNow(); this.Recv(); this.TimerOut(); foreach (long id in updateChannels) { KChannel kChannel; if (!this.idChannels.TryGetValue(id, out kChannel)) { continue; } if (kChannel.Id == 0) { continue; } kChannel.Update(this.TimeNow); } this.updateChannels.Clear(); while (true) { if (this.removedChannels.Count <= 0) { break; } long id = this.removedChannels.Dequeue(); this.idChannels.Remove(id); } }
/// 控制 跳跃 static void ControlJump(this TranslateComponent self) { if (Input.GetButton("Jump") && self.IsGrounded())//如果点击了触发跳跃的键盘按钮的话 { //每点击一次,上升。 上升的中途过程中,如果再次点击,就再次上升。上升到某个临界值,开始下降,下降到地面,就取消Jump。停止Jump运算 if (self.IsJumpUp && self.IsJump) { //刷新起始跳跃速度 self.actuallySpeed = self.jumpSpeed;//每点一次跳跃都要设置初始速度单位 return; } if (self.IsJumpDown && self.IsJump) { //刷新跳跃速度 self.actuallySpeed = self.jumpSpeed;//每点一次跳跃都要设置初始速度单位 self.IsJumpUp = true; self.IsJumpDown = false; return; } self.actuallySpeed = self.jumpSpeed;//每点一次跳跃都要设置初始速度单位 self.IsJump = true; self.IsJumpUp = true; } if (self.IsJump) { if (self.IsJumpUp) //还在上升期 { self.GetParent <Unit>().GameObject.transform.Translate(new Vector3(0, self.actuallySpeed * Time.deltaTime, 0)); self.actuallySpeed -= self.gravity; if (self.actuallySpeed <= 0) { Debug.Log("switch"); self.IsJumpDown = true; self.IsJumpUp = false; } } if (self.IsJumpDown) //朝下 { self.GetParent <Unit>().GameObject.transform.Translate(new Vector3(0, -self.actuallySpeed * Time.deltaTime, 0)); self.actuallySpeed += self.gravity; //加速下落 Position的Y 轴一直在减少 if (self.GetParent <Unit>().GameObject.transform.position.y <= self.gdy) { Vector3 currentPosition = self.GetParent <Unit>().GameObject.transform.position; self.GetParent <Unit>().GameObject.transform.position = new Vector3(currentPosition.x, 0, currentPosition.z); self.IsJumpDown = false; self.IsJump = false; self.actuallySpeed = self.jumpSpeed; } } Debug.Log(" TranslateComponentHelper-229: " + TimeHelper.ClientNow() + " Jump: " + self.GetParent <Unit>().Position); } }
public KService() { this.StartTime = TimeHelper.ClientNow(); this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //this.socket.Blocking = false; this.socket.Bind(new IPEndPoint(IPAddress.Any, 0)); Instance = this; }
public KService(IPEndPoint ipEndPoint, Action <AChannel> acceptCallback) { this.AcceptCallback += acceptCallback; this.StartTime = TimeHelper.ClientNow(); this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //this.socket.Blocking = false; this.socket.Bind(ipEndPoint); Instance = this; }
public KService() { this.TimeNow = (uint)TimeHelper.ClientNow(); this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.socket.Bind(new IPEndPoint(IPAddress.Any, 0)); #if SERVER if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { const uint IOC_IN = 0x80000000; const uint IOC_VENDOR = 0x18000000; uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; this.socket.IOControl((int)SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null); } #endif }
public KService(IPEndPoint ipEndPoint, Action <AChannel> acceptCallback) { this.AcceptCallback += acceptCallback; this.StartTime = TimeHelper.ClientNow(); this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //this.socket.Blocking = false; this.socket.Bind(ipEndPoint); #if SERVER if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { const uint IOC_IN = 0x80000000; const uint IOC_VENDOR = 0x18000000; uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; this.socket.IOControl((int)SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null); } #endif Instance = this; }
public override void Update() { this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.Recv(); foreach (var kv in this.localConnChannels) { kv.Value.Update(); } while (true) { if (this.removedChannels.Count <= 0) { break; } long id = this.removedChannels.Dequeue(); this.localConnChannels.Remove(id); } }
// 计算到期需要update的channel private void TimerOut() { if (this.timeId.Count == 0) { return; } long timeNow = TimeHelper.ClientNow(); this.TimeNow = (uint)timeNow; if (timeNow < this.minTime) { return; } this.timeOutTime.Clear(); foreach (KeyValuePair <long, List <long> > kv in this.timeId.GetDictionary()) { long k = kv.Key; if (k > timeNow) { minTime = k; break; } this.timeOutTime.Add(k); } foreach (long k in this.timeOutTime) { foreach (long v in this.timeId[k]) { this.updateChannels.Add(v); } this.timeId.Remove(k); } }
public override void Update() { this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.Recv(); foreach (var kv in this.localConnChannels) { kv.Value.Update(); } while (this.removedChannels.Count > 0) { long id = this.removedChannels.Dequeue(); KChannel channel; if (!this.localConnChannels.TryGetValue(id, out channel)) { continue; } this.localConnChannels.Remove(id); channel.Dispose(); } }
public async Task Send(Session session, int j) { try { await session.Call(new C2R_Ping()); ++this.k; if (this.k % 100000 != 0) { return; } long time2 = TimeHelper.ClientNow(); long time = time2 - this.time1; this.time1 = time2; Log.Info($"Benchmark k: {this.k} 每10W次耗时: {time} ms"); } catch (Exception e) { Log.Error(e.ToString()); } }