From 14bbbbacd46a088fd33de6e357bdb4ddb169db4a Mon Sep 17 00:00:00 2001 From: Victor Chelaru Date: Mon, 11 Mar 2019 22:59:16 -0600 Subject: [PATCH] Moved NetworkManager to a singleton pattern. --- NetworkManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/NetworkManager.cs b/NetworkManager.cs index e3683fe..c03726c 100644 --- a/NetworkManager.cs +++ b/NetworkManager.cs @@ -24,7 +24,7 @@ public static NetworkManager Self { if(self == null) { - throw new InvalidOperationException("NetworkManager must first be constructed in a class such as Game1"); + self = new NetworkManager(); } return self; } @@ -159,6 +159,11 @@ public INetworkArena GameArena private INetworkArena mGameArena; + NetworkManager() + { + + } + /// /// Instantiate the Network. /// WARNING: If no logger is provided, all messages will be swallowed. @@ -166,7 +171,7 @@ public INetworkArena GameArena /// Configuration for networking /// The game arena /// An ILogger to write messages to - public NetworkManager(NetworkConfiguration config, ILogger log = null) + public void Initialize(NetworkConfiguration config, ILogger log = null) { self = this; Configuration = config;