private void ZDK_NET_OnCallNetworkStatistics(Call call, NetworkStatistics networkStatistics) { if (OnZoiperEvent != null) { OnZoiperEvent("OnCallNetworkStatistics TotalOutputBytes: " + networkStatistics.TotalOutputBytes); } }
public override void Update() { SafeDisplay = Display; if (Display && Time.realtimeSinceStartup - LastUpdateTime > DisplayUpdateInterval || DisplayFast) { LastUpdateTime = Time.realtimeSinceStartup; //Vector text if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.ready && FlightGlobals.ActiveVessel != null) { var ourVessel = FlightGlobals.ActiveVessel; VectorText = $"Forward vector: {ourVessel.GetFwdVector()}\n"; VectorText += $"Up vector: {(Vector3)ourVessel.upAxis}\n"; VectorText += $"Srf Rotation: {ourVessel.srfRelRotation}\n"; VectorText += $"Vessel Rotation: {ourVessel.transform.rotation}\n"; VectorText += $"Vessel Local Rotation: {ourVessel.transform.localRotation}\n"; VectorText += $"mainBody Rotation: {(Quaternion)ourVessel.mainBody.rotation}\n"; VectorText += $"mainBody Transform Rotation: {ourVessel.mainBody.bodyTransform.rotation}\n"; VectorText += $"Surface Velocity: {ourVessel.GetSrfVelocity()}, |v|: {ourVessel.GetSrfVelocity().magnitude}\n"; VectorText += $"Orbital Velocity: {ourVessel.GetObtVelocity()}, |v|: {ourVessel.GetObtVelocity().magnitude}\n"; if (ourVessel.orbitDriver != null && ourVessel.orbitDriver.orbit != null) { VectorText += $"Frame Velocity: {(Vector3)ourVessel.orbitDriver.orbit.GetFrameVel()}, |v|: {ourVessel.orbitDriver.orbit.GetFrameVel().magnitude}\n"; } VectorText += $"CoM offset vector: {ourVessel.CoM}\n"; VectorText += $"Angular Velocity: {ourVessel.angularVelocity}, |v|: {ourVessel.angularVelocity.magnitude}\n"; VectorText += $"World Pos: {(Vector3)ourVessel.GetWorldPos3D()}, |pos|: {ourVessel.GetWorldPos3D().magnitude}\n"; } else { VectorText = "You have to be in flight"; } //NTP text NtpText = $"Warp rate: {Math.Round(Time.timeScale, 3)}x.\n"; NtpText += $"Current subspace: {SystemsContainer.Get<WarpSystem>().CurrentSubspace}.\n"; NtpText += $"Current Error: {Math.Round(SystemsContainer.Get<TimeSyncerSystem>().GetCurrentError() * 1000, 0)}ms.\n"; NtpText += $"Current universe time: {Math.Round(Planetarium.GetUniversalTime(), 3)} UT\n"; NtpText += $"Network latency: {Math.Round(SystemsContainer.Get<TimeSyncerSystem>().NetworkLatencyAverage / 10000f, 3)}ms\n"; NtpText += $"Server clock difference: {Math.Round(SystemsContainer.Get<TimeSyncerSystem>().ClockOffsetAverage / 10000f, 3)}ms\n"; NtpText += $"Server lag: {Math.Round(SystemsContainer.Get<TimeSyncerSystem>().ServerLag / 10000f, 3)}ms\n"; //Connection queue text ConnectionText = $"Ping: {NetworkStatistics.GetStatistics("Ping")}ms.\n"; ConnectionText += $"Last send time: {NetworkStatistics.GetStatistics("LastSendTime")}ms ago.\n"; ConnectionText += $"Last receive time: {NetworkStatistics.GetStatistics("LastReceiveTime")}ms ago.\n"; ConnectionText += $"Sent bytes: {NetworkStatistics.GetStatistics("SentBytes")}.\n"; ConnectionText += $"Received bytes: {NetworkStatistics.GetStatistics("ReceivedBytes")}.\n"; ConnectionText += $"Queued out msgs: {NetworkStatistics.GetStatistics("QueuedOutgoingMessages")}.\n"; //Vessel update system VesselUpdateText = $"Queued messages: {SystemsContainer.Get<VesselUpdateSystem>().MessageHandler.IncomingMessages.Count}.\n"; VesselUpdateText += $"Spectating: {VesselCommon.IsSpectating}.\n"; VesselUpdateText += "Active vessel control lock: " + $"{FlightGlobals.ActiveVessel != null && LockSystem.LockQuery.ControlLockBelongsToPlayer(FlightGlobals.ActiveVessel.id, SettingsSystem.CurrentSettings.PlayerName)}.\n"; VesselUpdateText += "Active vessel update lock: " + $"{FlightGlobals.ActiveVessel != null && LockSystem.LockQuery.UpdateLockBelongsToPlayer(FlightGlobals.ActiveVessel.id, SettingsSystem.CurrentSettings.PlayerName)}.\n"; } }
internal void Cooldown() { new Task(() => { Thread.Sleep(10000); NetworkStatistics.Remove(this); }).Start(); }
internal static void ServerConsole() { if (Interface.Oxide.ServerConsole == null || GameManager.Instance.GameState != EGameState.Hosting) { return; } Interface.Oxide.ServerConsole.Title = () => $"{GameManager.Instance.GetPlayerCount()} | {GameManager.Instance.ServerConfig.GameName}"; Interface.Oxide.ServerConsole.Status1Left = () => GameManager.Instance.ServerConfig.GameName; Interface.Oxide.ServerConsole.Status1Right = () => { TimeSpan time = TimeSpan.FromSeconds(Time.realtimeSinceStartup); string uptime = $"{time.TotalHours:00}h{time.Minutes:00}m{time.Seconds:00}s".TrimStart(' ', 'd', 'h', 'm', 's', '0'); return($"{Mathf.RoundToInt(1f / Time.smoothDeltaTime)}fps, {uptime}"); }; Interface.Oxide.ServerConsole.Status2Left = () => $"{GameManager.Instance.GetPlayerCount()}/{GameManager.Instance.ServerConfig.MaxPlayers} players"; Interface.Oxide.ServerConsole.Status2Right = () => { if (NetworkTime.serverTime <= 0) { return("not connected"); } double bytesReceived = 0; double bytesSent = 0; foreach (NetworkPlayer connection in uLink.Network.connections) { NetworkStatistics stats = connection.statistics; if (stats != null) { bytesReceived += stats.bytesReceivedPerSecond; bytesSent += stats.bytesSentPerSecond; } } return($"{Utility.FormatBytes(bytesReceived)}/s in, {Utility.FormatBytes(bytesSent)}/s out"); }; Interface.Oxide.ServerConsole.Status3Left = () => { if (TimeManager.Instance != null && GameManager.Instance != null) { GameTime time = TimeManager.Instance.GetCurrentGameTime(); string gameTime = Convert.ToDateTime($"{time.Hour}:{time.Minute}:{Math.Floor(time.Second)}").ToString("h:mm tt"); return($"{gameTime.ToLower()}, {GameManager.Instance.ServerConfig?.Map ?? "Unknown"}"); } return(string.Empty); }; Interface.Oxide.ServerConsole.Status3Right = () => $"Oxide.Hurtworld {AssemblyVersion}"; Interface.Oxide.ServerConsole.Status3RightColor = ConsoleColor.Yellow; }
public UnauthenticatedModule() { Get("/api/playerCount", async(_) => { PlayerCountResponseModel resp = null; Gate.RunGatedAction(() => resp = new PlayerCountResponseModel() { Online = PlayerManager.GetAllOnline().Count, Offline = PlayerManager.GetAllOffline().Count }); return(resp.AsJsonWebResponse()); }); Get("/api/networkStats", async(_) => { return(new NetworkStatsResponseModel() { C2S_CRCErrors_Aggregate = NetworkStatistics.C2S_CRCErrors_Aggregate, C2S_Packets_Aggregate = NetworkStatistics.C2S_Packets_Aggregate, C2S_RequestsForRetransmit_Aggregate = NetworkStatistics.C2S_RequestsForRetransmit_Aggregate, S2C_Packets_Aggregate = NetworkStatistics.S2C_Packets_Aggregate, S2C_RequestsForRetransmit_Aggregate = NetworkStatistics.S2C_RequestsForRetransmit_Aggregate, Summary = NetworkStatistics.Summary() }.AsJsonWebResponse()); }); Get("/api/serverStatus", async(_) => { string resp = null; Gate.RunGatedAction(() => resp = AdminCommands.GetServerStatus()); return(resp.AsJsonWebResponse()); }); Get("/api/serverInfo", async(_) => { ServerInfoResponseModel resp = null; Gate.RunGatedAction(() => resp = new ServerInfoResponseModel() { PlayerCount = new PlayerCountResponseModel() { Online = PlayerManager.GetAllOnline().Count, Offline = PlayerManager.GetAllOffline().Count }, Uptime = Timers.RunningTime, WorldName = ConfigManager.Config.Server.WorldName, AccountDefaults = ConfigManager.Config.Server.Accounts, MaximumAllowedSessions = ConfigManager.Config.Server.Network.MaximumAllowedSessions, ServerMotd = PropertyManager.GetString("server_motd").Item, PopupMotd = PropertyManager.GetString("popup_motd").Item, }); return(resp.AsJsonWebResponse()); }); }
private IEnumerator Start() { if (string.IsNullOrEmpty(savePath)) savePath = System.IO.Path.GetFullPath(UnityEngine.Application.dataPath + "/../Network Statistics Plots/" + System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff") + "/"); m_statisticsList = new List<NetworkStatistics>(); while (true) { yield return new WaitForSeconds(saveFrequency); var stats = new NetworkStatistics(); stats.CalculateNetworkStats(); m_statisticsList.Add(stats); } }
public void GetStatistics() { mockServer.ExpectNewRequest() .AndExpectUri("https://api.linkedin.com/v1/people/~/network/network-stats?format=json") .AndExpectMethod(HttpMethod.GET) .AndRespondWith(JsonResource("Statistics"), responseHeaders); #if NET_4_0 || SILVERLIGHT_5 NetworkStatistics stats = linkedIn.ConnectionOperations.GetNetworkStatisticsAsync().Result; #else NetworkStatistics stats = linkedIn.ConnectionOperations.GetNetworkStatistics(); #endif Assert.AreEqual(189, stats.FirstDegreeCount); Assert.AreEqual(50803, stats.SecondDegreeCount); }
public override void Update() { SafeDisplay = Display; if ((Display && (Time.realtimeSinceStartup - LastUpdateTime > DisplayUpdateInterval)) || DisplayFast) { LastUpdateTime = Time.realtimeSinceStartup; //Vector text if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && FlightGlobals.ready && (FlightGlobals.ActiveVessel != null)) { var ourVessel = FlightGlobals.ActiveVessel; VectorText = "Forward vector: " + ourVessel.GetFwdVector() + "\n"; VectorText += "Up vector: " + (Vector3)ourVessel.upAxis + "\n"; VectorText += "Srf Rotation: " + ourVessel.srfRelRotation + "\n"; VectorText += "Vessel Rotation: " + ourVessel.transform.rotation + "\n"; VectorText += "Vessel Local Rotation: " + ourVessel.transform.localRotation + "\n"; VectorText += "mainBody Rotation: " + (Quaternion)ourVessel.mainBody.rotation + "\n"; VectorText += "mainBody Transform Rotation: " + ourVessel.mainBody.bodyTransform.rotation + "\n"; VectorText += "Surface Velocity: " + ourVessel.GetSrfVelocity() + ", |v|: " + ourVessel.GetSrfVelocity().magnitude + "\n"; VectorText += "Orbital Velocity: " + ourVessel.GetObtVelocity() + ", |v|: " + ourVessel.GetObtVelocity().magnitude + "\n"; if ((ourVessel.orbitDriver != null) && (ourVessel.orbitDriver.orbit != null)) { VectorText += "Frame Velocity: " + (Vector3)ourVessel.orbitDriver.orbit.GetFrameVel() + ", |v|: " + ourVessel.orbitDriver.orbit.GetFrameVel().magnitude + "\n"; } VectorText += "CoM offset vector: " + ourVessel.CoM + "\n"; VectorText += "Angular Velocity: " + ourVessel.angularVelocity + ", |v|: " + ourVessel.angularVelocity.magnitude + "\n"; VectorText += "World Pos: " + (Vector3)ourVessel.GetWorldPos3D() + ", |pos|: " + ourVessel.GetWorldPos3D().magnitude + "\n"; } else { VectorText = "You have to be in flight"; } //NTP text NtpText = $"Warp rate: {Math.Round(Time.timeScale, 3)}x.\n"; NtpText += $"Current subspace: {WarpSystem.Singleton.CurrentSubspace}.\n"; NtpText += $"Current Error: {Math.Round(TimeSyncerSystem.Singleton.GetCurrentError()*1000, 0)}ms.\n"; NtpText += $"Current universe time: {Math.Round(Planetarium.GetUniversalTime(), 3)} UT\n"; NtpText += $"Network latency: {Math.Round(TimeSyncerSystem.Singleton.NetworkLatencyAverage/10000f, 3)}ms\n"; NtpText += $"Server clock difference: {Math.Round(TimeSyncerSystem.Singleton.ClockOffsetAverage/10000f, 3)}ms\n"; NtpText += $"Server lag: {Math.Round(TimeSyncerSystem.Singleton.ServerLag/10000f, 3)}ms\n"; //Connection queue text ConnectionText = $"Ping: {NetworkStatistics.GetStatistics("Ping")}ms.\n"; ConnectionText += $"Last send time: {NetworkStatistics.GetStatistics("LastSendTime")}ms ago.\n"; ConnectionText += $"Last receive time: {NetworkStatistics.GetStatistics("LastReceiveTime")}ms ago.\n"; ConnectionText += $"Sent bytes: {NetworkStatistics.GetStatistics("SentBytes")}.\n"; ConnectionText += $"Received bytes: {NetworkStatistics.GetStatistics("ReceivedBytes")}.\n"; ConnectionText += $"Queued out msgs: {NetworkStatistics.GetStatistics("QueuedOutgoingMessages")}.\n"; //Vessel update system VesselUpdateText = $"Queued messages: {VesselUpdateSystem.Singleton.MessageHandler.IncomingMessages.Count}.\n"; VesselUpdateText += $"Total queued updates: {VesselPositionSystem.Singleton.GetNumberOfPositionUpdatesInQueue()}.\n"; if (VesselPositionSystem.Singleton.ReceivedUpdates.Any()) { VesselUpdateText += "Queued updates by vessel:\n"; foreach (var vessel in VesselPositionSystem.Singleton.ReceivedUpdates.Keys) { VesselUpdateText += $"{vessel}: {VesselPositionSystem.Singleton.GetNumberOfPositionUpdatesInQueue(vessel)} - " + $"Interpolation factor:{VesselPositionInterpolationSystem.GetInterpolationFactor(vessel)}\n"; } } VesselUpdateText += $"Spectating: {VesselCommon.IsSpectating}.\n"; VesselUpdateText += "Active vessel control lock: " + $"{FlightGlobals.ActiveVessel != null && LockSystem.Singleton.LockIsOurs("control-" + FlightGlobals.ActiveVessel.id)}.\n"; VesselUpdateText += "Active vessel update lock: " + $"{FlightGlobals.ActiveVessel != null && LockSystem.Singleton.LockIsOurs("update-" + FlightGlobals.ActiveVessel.id)}.\n"; ProfilerText = "Update: \n" + LunaProfiler.UpdateData; ProfilerText += "Fixed Update: \n" + LunaProfiler.FixedUpdateData; ProfilerText += "GUI: \n" + LunaProfiler.GuiData; ProfilerText += "Custom 1: \n" + LunaProfiler.GuiData; ProfilerText += "Custom 2: \n" + LunaProfiler.GuiData; } }