Skip to content

Commit 3673ffc

Browse files
refactor: remove NetworkManager.Singleton dependencies, add additional instance tracking and notification when LogLevel.Developer (#562)
* refactor: better handle instantiating and lack of a NetworkManager This refactoring includes additional checks to assure the RpcQueueContainer does not allow itself to be updated via the Network Update Loop system if there is no NetworkManager instantiated or if there is a problem with its initialization. Refactored the constructor and made the class disposable. * fix: increment the instance count before logging Placing the increment above the log. * Revert "fix: increment the instance count before logging" This reverts commit 3890232. * fix: increment before log Moving the instance count above the logging of the instance count * style: typo on the shutting down message Had a typo that said it was initializing as opposed to shutting down. * refactor: Remove all NetworkManager.Singleton dependencies This refactor passes the RpcQueueContainer into the RpcQueueProcessor in order to start remove the RpcQueueContainer's dependencies on the NetworkManager.Singleton. This refactor removes RpcQueueContainer 's dependencies upon the NetworkManager.Singleton by passing the instance of the NetworkManager that constructed it. This should remove all dependencies from NetworkManager.Singleton from the entire Rpc Queue System! * refactor: further improved dependencies and expanded unit testing This commit further improves the previous dependencies upon NetworkManager. This also expands unit testing capabilities that now can include RpcQueueProcessor. ( just detecting if we are listening or testing ) * Update com.unity.multiplayer.mlapi/Runtime/Messaging/RpcQueue/RpcQueueContainer.cs Good addition, this will assure that anyone that changes the name of the class will see the name mismatch and update the log, Co-authored-by: M. Fatih MAR <[email protected]> * Update com.unity.multiplayer.mlapi/Runtime/Messaging/RpcQueue/RpcQueueContainer.cs Same catch.. I like that approach! Co-authored-by: M. Fatih MAR <[email protected]> * style and developer: Updated some minor standards related issues and wrapped all of the debug logging related code in #if UNITY_EDITOR || DEVELOPMENT_BUILD * fix: Typo in Fatih's committed suggested fix. :alien: * refactor: updated minor debug messages. This assures that all log related messages utilize the appropriate class names. This removes some legacy language from the log related messages. * style Some minor tweaks for camelCase and spacing. * style Filled out the rest of the summary for the NetworkUpdate metod in RpcQueueContainer. * minor update * refactor: Wrapping UNITY_EDITOR || DEVELOPMENT_BUILD around a log message and the s_RpcQueueContainerInstances property. Co-authored-by: M. Fatih MAR <[email protected]>
1 parent db4f940 commit 3673ffc

File tree

3 files changed

+211
-141
lines changed

3 files changed

+211
-141
lines changed

com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,13 @@ private void Init(bool server)
324324
if (RpcQueueContainer != null)
325325
{
326326
UnityEngine.Debug.LogError("Init was invoked, but rpcQueueContainer was already initialized! (destroying previous instance)");
327-
RpcQueueContainer.Shutdown();
327+
RpcQueueContainer.Dispose();
328328
RpcQueueContainer = null;
329329
}
330330

331331
//The RpcQueueContainer must be initialized within the Init method ONLY
332332
//It should ONLY be shutdown and destroyed in the Shutdown method (other than just above)
333-
RpcQueueContainer = new RpcQueueContainer(false);
334-
335-
//Note: Since frame history is not being used, this is set to 0
336-
//To test frame history, increase the number to (n) where n > 0
337-
RpcQueueContainer.Initialize(0);
333+
RpcQueueContainer = new RpcQueueContainer(this);
338334

339335
// Register INetworkUpdateSystem (always register this after rpcQueueContainer has been instantiated)
340336
this.RegisterNetworkUpdate(NetworkUpdateStage.EarlyUpdate);
@@ -599,7 +595,7 @@ public void Shutdown()
599595
//If an instance of the RpcQueueContainer is still around, then shut it down and remove the reference
600596
if (RpcQueueContainer != null)
601597
{
602-
RpcQueueContainer.Shutdown();
598+
RpcQueueContainer.Dispose();
603599
RpcQueueContainer = null;
604600
}
605601

0 commit comments

Comments
 (0)