/// <summary> /// Return the xfer uploader for the given transaction. /// </summary> /// <remarks> /// If an uploader does not already exist for this transaction then it is created, otherwise the existing /// uploader is returned. /// </remarks> /// <param name="transactionID"></param> /// <returns>The asset xfer uploader</returns> public AssetXferUploader RequestXferUploader(UUID transactionID) { AssetXferUploader uploader; lock (XferUploaders) { if (!XferUploaders.ContainsKey(transactionID)) { uploader = new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile); // MainConsole.Instance.DebugFormat( // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); XferUploaders.Add(transactionID, uploader); } else { uploader = XferUploaders[transactionID]; } } IMonitorModule monitorModule = m_Scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_Scene); networkMonitor.AddPendingUploads(1); } return(uploader); }
protected void SendCompleteMessage(IClientAPI remoteClient) { lock (_finishedLock) { m_finished = true; if (FinishedEvent != null) { FinishedEvent(); } if (m_createItem) { DoCreateItem(m_createItemCallback, remoteClient); } else if (m_storeLocal) { m_asset.ID = m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); } } remoteClient.SendAssetUploadCompleteMessage((sbyte)m_asset.Type, true, m_asset.ID); IMonitorModule monitorModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(m_userTransactions.Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } MainConsole.Instance.DebugFormat( "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.ID, TransactionID); }
public static Task <bool> CanReachAsync(this INetworkMonitor monitor, IntPtr connectable, IntPtr cancellable = default(IntPtr)) { if (monitor == null) { throw new ArgumentNullException(nameof(monitor)); } var instance = (Object)monitor; var completion = new TaskCompletionSource <bool> (); Action <IntPtr, IntPtr, IntPtr> nativeCallback = (sourceObjectPtr, resultPtr, userDataPtr) => { IntPtr errorPtr; var ret = g_network_monitor_can_reach_async_finish(sourceObjectPtr, resultPtr, out errorPtr); if (errorPtr != IntPtr.Zero) { var error = Opaque.GetInstance <Error> (errorPtr, Transfer.Full); completion.SetException(new GErrorException(error)); } else { completion.SetResult(ret); } GCHandle.FromIntPtr(userDataPtr).Free(); }; var callbackGCHandle = GCHandle.Alloc(nativeCallback); g_network_monitor_can_reach_async(instance.Handle, connectable, cancellable, nativeCallback, (IntPtr)callbackGCHandle); GC.KeepAlive(instance); return(completion.Task); }
protected void SendCompleteMessage(IClientAPI remoteClient) { remoteClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); m_finished = true; if (m_createItem) { DoCreateItem(m_createItemCallback, remoteClient); } else if (m_storeLocal) { m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); } IMonitorModule monitorModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(m_userTransactions.Manager.MyScene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(-1); } m_log.DebugFormat( "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); if (m_dumpAssetToFile) { DateTime now = DateTime.Now; string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); SaveAssetToFile(filename, m_asset.Data); } }
public static bool GetNetworkMetered(this INetworkMonitor monitor) { if (monitor == null) { throw new ArgumentNullException(nameof(monitor)); } var instance = (Object)monitor; var ret = g_network_monitor_get_network_metered(instance.Handle); GC.KeepAlive(instance); return(ret); }
//private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) //{ // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( // ourClient.AgentId); // if (userInfo != null) // { // InventoryItemBase item = new InventoryItemBase(); // item.Owner = ourClient.AgentId; // item.Creator = ourClient.AgentId; // item.ID = UUID.Random(); // item.AssetID = asset.FullID; // item.Description = asset.Description; // item.Name = asset.Name; // item.AssetType = asset.Type; // item.InvType = asset.Type; // item.Folder = inventoryFolderID; // item.BasePermissions = 0x7fffffff; // item.CurrentPermissions = 0x7fffffff; // item.EveryOnePermissions = 0; // item.NextPermissions = nextPerms; // item.Flags = wearableType; // item.CreationDate = Util.UnixTimeSinceEpoch(); // userInfo.AddItem(item); // ourClient.SendInventoryItemCreateUpdate(item); // } // else // { // MainConsole.Instance.ErrorFormat( // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", // ourClient.AgentId); // } //} public void RequestUpdateTaskInventoryItem( IClientAPI remoteClient, ISceneChildEntity part, UUID transactionID, TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { AssetBase asset = XferUploaders[transactionID].GetAssetData(); if (asset != null) { MainConsole.Instance.DebugFormat( "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", item.Name, part.Name, transactionID); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; item.AssetID = asset.ID; IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } asset.ID = Manager.MyScene.AssetService.Store(asset); item.AssetID = asset.ID; if (part.Inventory.UpdateInventoryItem(item)) { if ((InventoryType)item.InvType == InventoryType.Notecard) { remoteClient.SendAgentAlertMessage("Notecard saved", false); } else if ((InventoryType)item.InvType == InventoryType.LSL) { remoteClient.SendAgentAlertMessage("Script saved", false); } else { remoteClient.SendAgentAlertMessage("Item saved", false); } part.GetProperties(remoteClient); } } } }
/// <summary> /// Handle asset transfer data packets received in response to the asset upload request in /// HandleUDPUploadRequest() /// </summary> /// <param name="remoteClient"></param> /// <param name="xferID"></param> /// <param name="packetID"></param> /// <param name="data"></param> public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(1); } transactions.HandleXfer(remoteClient, xferID, packetID, data); }
/// <summary> /// Handle asset transfer data packets received in response to the asset upload request in /// HandleUDPUploadRequest() /// </summary> /// <param name="remoteClient"></param> /// <param name="xferID"></param> /// <param name="packetID"></param> /// <param name="data"></param> public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { //MainConsole.Instance.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene); networkMonitor.AddPendingUploads(1); } transactions.HandleXfer(remoteClient, xferID, packetID, data); }
public JsonDataStore(IDataCache cache, ILogger logger, INetworkMonitor networkMonitor, IEventDayService service = null) { _networkMonitor = networkMonitor; _logger = logger.CreateLogger("DataStore"); _cache = new MemoryDataCache(cache, logger); _service = service ?? new EventDayService(); try { _messageBus = DependencyService.Get <IMessageBus>(); } catch (Exception e) { _logger.Warn(e.Message); } }
private void DoCreateItem(uint callbackID, IClientAPI remoteClient) { m_asset.ID = m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); IMonitorModule monitorModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(m_userTransactions.Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } InventoryItemBase item = new InventoryItemBase { Owner = remoteClient.AgentId, CreatorId = remoteClient.AgentId.ToString(), ID = UUID.Random(), AssetID = m_asset.ID, Description = m_description, Name = m_name, AssetType = type, InvType = invType, Folder = InventFolder, BasePermissions = 0x7fffffff, CurrentPermissions = 0x7fffffff, GroupPermissions = 0, EveryOnePermissions = 0, NextPermissions = nextPerm, Flags = wearableType, CreationDate = Util.UnixTimeSinceEpoch() }; ILLClientInventory inventoryModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <ILLClientInventory>(); if (inventoryModule != null && inventoryModule.AddInventoryItem(item)) { remoteClient.SendInventoryItemCreateUpdate(item, callbackID); } else { remoteClient.SendAlertMessage("Unable to create inventory item"); } }
/// <summary> /// Update a task inventory item with data that has been received through a transaction. /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction /// and comes through this method. /// </summary> /// <param name="remoteClient"></param> /// <param name="part"></param> /// <param name="transactionID"></param> /// <param name="item"></param> public void HandleTaskItemUpdateFromTransaction( IClientAPI remoteClient, ISceneChildEntity part, UUID transactionID, TaskInventoryItem item) { // MainConsole.Instance.DebugFormat("[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", item.Name); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene); networkMonitor.AddPendingUploads(1); } transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); }
public static bool CanReach(this INetworkMonitor monitor, IntPtr connectable, IntPtr cancellable = default(IntPtr)) { if (monitor == null) { throw new ArgumentNullException(nameof(monitor)); } var instance = (Object)monitor; var ret = g_network_monitor_can_reach(instance.Handle, connectable, cancellable, out var errorPtr); GC.KeepAlive(instance); if (errorPtr != IntPtr.Zero) { var error = Opaque.GetInstance <Error> (errorPtr, Transfer.Full); throw new GErrorException(error); } return(ret); }
/// <summary> /// Update an inventory item with data that has been received through a transaction. /// /// This is called when clothing or body parts are updated (for instance, with new textures or /// colours). It may also be called in other situations. /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="item"></param> public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) { // m_log.DebugFormat( // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", // item.Name); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(1); } transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); }
/// <summary> /// Request that a client (agent) begin an asset transfer. /// </summary> /// <param name = "remoteClient"></param> /// <param name = "assetID"></param> /// <param name = "transaction"></param> /// <param name = "type"></param> /// <param name = "data"></param> /// </param> /// <param name = "tempFile"></param> public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal, bool tempFile) { // MainConsole.Instance.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); if (((AssetType)type == AssetType.Texture || (AssetType)type == AssetType.Sound || (AssetType)type == AssetType.TextureTGA || (AssetType)type == AssetType.Animation) && tempFile == false) { IScene scene = remoteClient.Scene; IMoneyModule mm = scene.RequestModuleInterface <IMoneyModule>(); if (mm != null) { if (!mm.Charge(remoteClient, mm.UploadCharge)) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); return; } } } AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(1); } AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); } }
/// <summary> /// Create an inventory item from data that has been received through a transaction. /// This is called when new clothing or body parts are created. It may also be called in other /// situations. /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="folderID"></param> /// <param name="callbackID"></param> /// <param name="description"></param> /// <param name="name"></param> /// <param name="invType"></param> /// <param name="type"></param> /// <param name="wearableType"></param> /// <param name="nextOwnerMask"></param> public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) { // MainConsole.Instance.DebugFormat("[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene); networkMonitor.AddPendingUploads(1); } transactions.RequestCreateInventoryItem( remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); }
public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) { if (XferUploaders.ContainsKey(transactionID)) { UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); if (asset == null) { asset = GetTransactionAsset(transactionID); } if (asset != null && asset.ID == assetID) { // Assets never get updated, new ones get created asset.ID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.AssetType; item.AssetID = asset.ID; asset.ID = Manager.MyScene.AssetService.Store(asset); item.AssetID = asset.ID; } IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } IInventoryService invService = Manager.MyScene.InventoryService; invService.UpdateItem(item); } }
private void UpdateInventoryItemWithAsset(InventoryItemBase item, UUID assetID, UUID transactionID) { AssetXferUploader uploader = XferUploaders[transactionID]; AssetBase asset = uploader.GetAssetData(); if (asset != null && asset.ID == assetID) { // Assets never get updated, new ones get created asset.ID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.AssetType; item.AssetID = asset.ID; asset.ID = Manager.MyScene.AssetService.Store(asset); item.AssetID = asset.ID; XferUploaders.Remove(transactionID); } else { return; } IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } IInventoryService invService = Manager.MyScene.InventoryService; invService.UpdateItem(item); }
/// <summary> /// This is called by a timer and makes a SimStats class of the current stats that we have in this simulator. /// It then sends the packet to the client and triggers the events to tell followers about the updated stats /// and updates the LastSet* values for monitors. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void statsHeartBeat(object sender, EventArgs e) { if (m_currentScene.PhysicsScene == null) { return; } m_report.Stop(); if (rb == null) { buildInitialRegionBlock(); } // Know what's not thread safe in Mono... modifying timers. lock (m_report) { ISimFrameMonitor simFrameMonitor = GetMonitor <ISimFrameMonitor>(); ITimeDilationMonitor timeDilationMonitor = GetMonitor <ITimeDilationMonitor>(); ITotalFrameTimeMonitor totalFrameMonitor = GetMonitor <ITotalFrameTimeMonitor>(); ISleepFrameMonitor sleepFrameMonitor = GetMonitor <ISleepFrameMonitor>(); IOtherFrameMonitor otherFrameMonitor = GetMonitor <IOtherFrameMonitor>(); IPhysicsFrameMonitor physicsFrameMonitor = GetMonitor <IPhysicsFrameMonitor>(); IPhysicsSyncFrameMonitor physicsSyncFrameMonitor = GetMonitor <IPhysicsSyncFrameMonitor>(); IPhysicsUpdateFrameMonitor physicsTimeFrameMonitor = GetMonitor <IPhysicsUpdateFrameMonitor>(); IAgentUpdateMonitor agentUpdateFrameMonitor = GetMonitor <IAgentUpdateMonitor>(); INetworkMonitor networkMonitor = GetMonitor <INetworkMonitor>(); IImageFrameTimeMonitor imagesMonitor = GetMonitor <IImageFrameTimeMonitor>(); IScriptFrameTimeMonitor scriptMonitor = GetMonitor <IScriptFrameTimeMonitor>(); IScriptCountMonitor totalScriptMonitor = GetMonitor <IScriptCountMonitor>(); #region various statistic googly moogly float simfps = simFrameMonitor.SimFPS / statsUpdateFactor; // save the reported value so there is something available for llGetRegionFPS simFrameMonitor.LastReportedSimFPS = simfps; float physfps = physicsFrameMonitor.PhysicsFPS / statsUpdateFactor; physicsFrameMonitor.LastReportedPhysicsFPS = physfps; //Update the time dilation with the newest physicsFPS timeDilationMonitor.SetPhysicsFPS(physfps); #endregion #region Add the stats packets //Some info on this packet http://wiki.secondlife.com/wiki/Statistics_Bar_Guide sb[0].StatID = (uint)Stats.TimeDilation; sb[0].StatValue = (float)timeDilationMonitor.GetValue(); sb[1].StatID = (uint)Stats.FPS; sb[1].StatValue = simfps; float realsimfps = simfps * 2; sb[2].StatID = (uint)Stats.PhysFPS; sb[2].StatValue = physfps; sb[3].StatID = (uint)Stats.AgentUpdates; sb[3].StatValue = (agentUpdateFrameMonitor.AgentUpdates / realsimfps); sb[4].StatID = (uint)Stats.FrameMS; float TotalFrames = (float)(totalFrameMonitor.GetValue() / realsimfps); sb[4].StatValue = TotalFrames; sb[5].StatID = (uint)Stats.NetMS; sb[5].StatValue = 0; //TODO: Implement this sb[6].StatID = (uint)Stats.SimOtherMS; float otherMS = (float)(otherFrameMonitor.GetValue() / realsimfps); sb[6].StatValue = otherMS; sb[7].StatID = (uint)Stats.SimPhysicsMS; float PhysicsMS = (float)(physicsTimeFrameMonitor.GetValue() / realsimfps); sb[7].StatValue = PhysicsMS; sb[8].StatID = (uint)Stats.AgentMS; sb[8].StatValue = (agentUpdateFrameMonitor.AgentFrameTime / realsimfps); sb[9].StatID = (uint)Stats.ImagesMS; float imageMS = (float)(imagesMonitor.GetValue() / realsimfps); sb[9].StatValue = imageMS; sb[10].StatID = (uint)Stats.ScriptMS; float ScriptMS = (float)(scriptMonitor.GetValue() / realsimfps); sb[10].StatValue = ScriptMS; sb[11].StatID = (uint)Stats.TotalObjects; sb[12].StatID = (uint)Stats.ActiveObjects; sb[13].StatID = (uint)Stats.NumAgentMain; sb[14].StatID = (uint)Stats.NumAgentChild; IEntityCountModule entityCountModule = m_currentScene.RequestModuleInterface <IEntityCountModule>(); if (entityCountModule != null) { sb[11].StatValue = entityCountModule.Objects; sb[12].StatValue = entityCountModule.ActiveObjects; sb[13].StatValue = entityCountModule.RootAgents; sb[14].StatValue = entityCountModule.ChildAgents; } sb[15].StatID = (uint)Stats.NumScriptActive; sb[15].StatValue = totalScriptMonitor.ActiveScripts; sb[16].StatID = (uint)Stats.LSLIPS; sb[16].StatValue = 0; //This isn't used anymore, and has been superseeded by LSLEPS sb[17].StatID = (uint)Stats.InPPS; sb[17].StatValue = (networkMonitor.InPacketsPerSecond / statsUpdateFactor); sb[18].StatID = (uint)Stats.OutPPS; sb[18].StatValue = (networkMonitor.OutPacketsPerSecond / statsUpdateFactor); sb[19].StatID = (uint)Stats.PendingDownloads; sb[19].StatValue = (networkMonitor.PendingDownloads); sb[20].StatID = (uint)Stats.PendingUploads; sb[20].StatValue = (networkMonitor.PendingUploads); //21 and 22 are forced to the GC memory as they WILL make memory usage go up rapidly otherwise! sb[21].StatID = (uint)Stats.VirtualSizeKB; sb[21].StatValue = GC.GetTotalMemory(false) / 1024; // System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024); sb[22].StatID = (uint)Stats.ResidentSizeKB; sb[22].StatValue = GC.GetTotalMemory(false) / 1024; //(float)System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / (1024); sb[23].StatID = (uint)Stats.PendingLocalUploads; sb[23].StatValue = (networkMonitor.PendingUploads / statsUpdateFactor); sb[24].StatID = (uint)Stats.TotalUnackedBytes; sb[24].StatValue = (networkMonitor.UnackedBytes); sb[25].StatID = (uint)Stats.PhysicsPinnedTasks; sb[25].StatValue = 0; sb[26].StatID = (uint)Stats.PhysicsLODTasks; sb[26].StatValue = 0; sb[27].StatID = (uint)Stats.SimPhysicsStepMS; sb[27].StatValue = m_currentScene.PhysicsScene.StepTime; sb[28].StatID = (uint)Stats.SimPhysicsShape; sb[28].StatValue = 0; sb[29].StatID = (uint)Stats.SimPhysicsOtherMS; sb[29].StatValue = (float)(physicsSyncFrameMonitor.GetValue() / realsimfps); sb[30].StatID = (uint)Stats.SimPhysicsMemory; sb[30].StatValue = 0; sb[31].StatID = (uint)Stats.ScriptEPS; sb[31].StatValue = totalScriptMonitor.ScriptEPS / statsUpdateFactor; sb[32].StatID = (uint)Stats.SimSpareTime; //Spare time is the total time minus the stats that are in the same category in the client // It is the sleep time, physics step, update physics shape, physics other, and pumpI0. // Note: take out agent Update and script time for now, as they are not a part of the heartbeat right now and will mess this calc up float SpareTime = TotalFrames - ( /*NetMS + */ PhysicsMS + otherMS + imageMS); // + /*(agentUpdateFrameMonitor.AgentFrameTime / statsUpdateFactor) +*/ // (imagesMonitor.GetValue() / statsUpdateFactor) /* + ScriptMS*/)); sb[32].StatValue = SpareTime; sb[33].StatID = (uint)Stats.SimSleepTime; sb[33].StatValue = (float)(sleepFrameMonitor.GetValue() / realsimfps); sb[34].StatID = (uint)Stats.IOPumpTime; sb[34].StatValue = 0; //TODO: implement this #endregion for (int i = 0; i < sb.Length; i++) { if (float.IsInfinity(sb[i].StatValue) || float.IsNaN(sb[i].StatValue)) { sb[i].StatValue = 0; //Don't send huge values } lastReportedSimStats[i] = sb[i].StatValue; } SimStats simStats = new SimStats(rb, sb, m_currentScene.RegionInfo.RegionID); //Fire the event and tell followers about the new stats m_module.SendStatsResults(simStats); //Tell all the scene presences about the new stats foreach (IScenePresence agent in m_currentScene.GetScenePresences().Where(agent => !agent.IsChildAgent)) { agent.ControllingClient.SendSimStats(simStats); } //Now fix any values that require reseting ResetValues(); } m_report.Start(); }
public PRServer(int port, NetworkObjectsManager manager, IRecordSentPackets sentPacketRecorder, IRecordReceivedPackets receivedPacketRecorder, INetworkMonitor monitor) { this.objectsManager = manager; this.sentPacketRecorder = sentPacketRecorder; this.receivedPacketRecorder = receivedPacketRecorder; this.monitor = monitor; udpClient = new UdpClient(47777); udpClient.Client.IOControl( (IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null ); udpClient.BeginReceive(new AsyncCallback(UdpServerData), udpClient); parsers.Add(Packet.PACKET_CONNECTIONREQUEST, ParseConnectionRequestPacket); parsers.Add(Packet.PACKET_CHALLENGERESPONSE, ParseChallengeResponsePacket); parsers.Add(Packet.PACKET_CLIENTREADY, ParseClientReadyPacket); parsers.Add(Packet.PACKET_ACK, ParseAck); parsers.Add(Packet.PACKET_STATEREQUEST, ParseStateRequestPacket); parsers.Add(Packet.PACKET_NETWORKMESSAGE, ServerStage.ParseNetworkMessages); parsers.Add(Packet.PACKET_CLIENTDISCONNECTED, ParseClientDisconnectPacket); Thread timeoutDetectionThread = new Thread(new ThreadStart(ChangeDetectionThread)); timeoutDetectionThread.Start(); }
static SessionManager () { NetworkMonitor = new NaïveNetworkMonitor (); }
static SessionManager() { NetworkMonitor = new NaïveNetworkMonitor(); }
public PRClient(NetworkObjectsManager manager, IRecordSentPackets sentPacketRecorder, IRecordReceivedPackets receivedPacketRecorder, INetworkMonitor monitor) { this.objectsManager = manager; this.sentPacketRecorder = sentPacketRecorder; this.receivedPacketRecorder = receivedPacketRecorder; this.monitor = monitor; IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] portInfo = properties.GetActiveUdpListeners(); List <int> ports = portInfo.Select(info => info.Port).ToList(); myPort = Identification.GetUniqueIdentifierFromList(ports, 5000, 50000); udpClient = new UdpClient(myPort); udpClient.Client.IOControl( (IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null ); udpClient.BeginReceive(new AsyncCallback(UdpClientData), udpClient); Debug.Log("Welcome to my client!"); Debug.Log("You have been assigned port # " + myPort); SetupParsers(); InitializeThreads(); }