private async void TestAsync(NetOuterComponent networkComponent, string address, int j) { try { using (Session session = networkComponent.Create(address)) { int i = 0; while (i < 10000000) { ++i; await session.Call <C2R_Ping, R2C_Ping>(new C2R_Ping()); ++this.k; if (this.k % 100000 != 0) { continue; } long time2 = TimeHelper.ClientNow(); long time = time2 - this.time1; this.time1 = time2; Log.Info($"{j} Benchmark k: {this.k} 每10W次耗时: {time} ms"); } } } catch (RpcException e) { Log.Error(e.ToString()); } catch (Exception e) { Log.Error(e.ToString()); } }
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); } }
public static void Debug(string msg) { #if UNITY_EDITOR DateTime dateTime = DateTime.Now; string s = $"{dateTime:yyyy-MM-dd HH:mm:ss} {TimeHelper.ClientNow()} {msg}"; UnityEngine.Debug.Log(s); info.WriteLine(s); if (IsNeedFlush) { info.Flush(); } #endif }
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 async Task Send(Session session, int j) { try { await session.Call <R2C_Ping>(new C2R_Ping()); ++this.k; if (this.k % 10000 != 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()); } }
public long Now() { return(TimeHelper.ClientNow() - this.syncClientTime + syncTime); }