private void OnUserConnected(object sender, NetEventArgs args) { var timer = GetTimer(args.User); P_Ping ping = new P_Ping(); ChPing.Send(new OutgoingMessage <P_Ping>(ping, args.User)); timer.Start(); connectedUsers.Add(args.User); }
private void OnPingReceived(IncomingMessage <P_Ping> obj) { if (IsServer) { var timer = GetTimer(obj.Sender); obj.Sender.SetLocal <double>(LatencyKey, timer.Elapsed.TotalSeconds); timer.Stop(); timer.Reset(); var user = obj.Sender; ScheduleEvent(new TimeSpan(0, 0, 0, 0, PingSendDelay), () => { P_Ping ping = new P_Ping(); ChPing.Send(new OutgoingMessage <P_Ping>(ping, user)); timer.Start(); }); } if (IsClient) { ChPing.Send(new OutgoingMessage <P_Ping>(obj.Data)); } }