From 7bf5c30de189db4327279b90df08d6abe0763743 Mon Sep 17 00:00:00 2001 From: Chillu1 Date: Sat, 6 Mar 2021 21:01:43 +0100 Subject: [PATCH] Updated insight to don't use depracated mirror logger from versions lower than v31.0.0 (2021-02-18) --- Assets/Insight/InsightClient.cs | 22 +++++++--------- Assets/Insight/InsightCommon.cs | 6 ++--- Assets/Insight/InsightNetworkConnection.cs | 14 +++++----- Assets/Insight/InsightServer.cs | 26 +++++++++---------- Assets/Insight/Modules/Chat/ChatClient.cs | 4 +-- Assets/Insight/Modules/Chat/ChatServer.cs | 4 +-- .../Modules/GameManager/ClientGameManager.cs | 8 +++--- .../Modules/GameManager/GameRegistration.cs | 14 +++++----- .../Modules/GameManager/ServerGameManager.cs | 10 +++---- Assets/Insight/Modules/InsightModule.cs | 6 ++--- .../Modules/Login/ClientAuthentication.cs | 8 +++--- .../Modules/Login/ServerAuthentication.cs | 4 +-- .../Insight/Modules/Master/MasterSpawner.cs | 16 +++++------- .../Modules/MatchMaking/ServerMatchMaking.cs | 14 +++++----- Assets/Insight/Modules/ModuleManager.cs | 6 ++--- .../Insight/Modules/Spawner/ProcessSpawner.cs | 15 +++++------ Assets/Insight/Modules/Spawner/ServerIdler.cs | 4 +-- 17 files changed, 74 insertions(+), 107 deletions(-) diff --git a/Assets/Insight/InsightClient.cs b/Assets/Insight/InsightClient.cs index 18b089f..f3f8a39 100644 --- a/Assets/Insight/InsightClient.cs +++ b/Assets/Insight/InsightClient.cs @@ -6,8 +6,6 @@ namespace Insight { public class InsightClient : InsightCommon { - static readonly ILogger logger = LogFactory.GetLogger(typeof(InsightClient)); - public bool AutoReconnect = true; protected int clientID = -1; //-1 = never connected, 0 = disconnected, 1 = connected protected int connectionID = 0; @@ -53,7 +51,7 @@ public void StartInsight(string Address) { if(string.IsNullOrEmpty(Address)) { - logger.LogError("[InsightClient] - Address provided in StartInsight is Null or Empty. Not Starting."); + Debug.LogError("[InsightClient] - Address provided in StartInsight is Null or Empty. Not Starting."); return; } @@ -92,7 +90,7 @@ private void CheckConnection() { if (!isConnected && (_reconnectTimer < Time.time)) { - logger.Log("[InsightClient] - Trying to reconnect..."); + Debug.Log("[InsightClient] - Trying to reconnect..."); _reconnectTimer = Time.realtimeSinceStartup + ReconnectDelayInSeconds; StartInsight(); } @@ -113,7 +111,7 @@ public void Send(T msg, CallbackHandler callback) where T : Message { if (!transport.ClientConnected()) { - logger.LogError("[InsightClient] - Client not connected!"); + Debug.LogError("[InsightClient] - Client not connected!"); return; } @@ -146,10 +144,10 @@ void OnConnected() { if (insightNetworkConnection != null) { - logger.Log("[InsightClient] - Connected to Insight Server"); + Debug.Log("[InsightClient] - Connected to Insight Server"); connectState = ConnectState.Connected; } - else logger.LogError("Skipped Connect message handling because m_Connection is null."); + else Debug.LogError("Skipped Connect message handling because m_Connection is null."); } void OnDisconnected() @@ -185,31 +183,31 @@ protected void HandleBytes(ArraySegment data, int i) else { //NOTE: this throws away the rest of the buffer. Need moar error codes - logger.LogError("Unknown message ID " + msgType);// + " connId:" + connectionId); + Debug.LogError("Unknown message ID " + msgType);// + " connId:" + connectionId); } } void OnError(Exception exception) { // TODO Let's discuss how we will handle errors - logger.LogException(exception); + Debug.LogException(exception); } void OnApplicationQuit() { - logger.Log("[InsightClient] Stopping Client"); + Debug.Log("[InsightClient] Stopping Client"); StopInsight(); } ////------------Virtual Handlers------------- public virtual void OnStartInsight() { - logger.Log("[InsightClient] - Connecting to Insight Server: " + networkAddress); + Debug.Log("[InsightClient] - Connecting to Insight Server: " + networkAddress); } public virtual void OnStopInsight() { - logger.Log("[InsightClient] - Disconnecting from Insight Server"); + Debug.Log("[InsightClient] - Disconnecting from Insight Server"); } } } diff --git a/Assets/Insight/InsightCommon.cs b/Assets/Insight/InsightCommon.cs index 0a74469..d0d5521 100644 --- a/Assets/Insight/InsightCommon.cs +++ b/Assets/Insight/InsightCommon.cs @@ -15,8 +15,6 @@ public enum CallbackStatus : byte public abstract class InsightCommon : MonoBehaviour { - static readonly ILogger logger = LogFactory.GetLogger(typeof(InsightCommon)); - public bool DontDestroy = true; //Sets DontDestroyOnLoad for this object. Default to true. Can be disabled via Inspector or runtime code. public bool AutoStart = true; public string networkAddress = "localhost"; @@ -49,7 +47,7 @@ public virtual Transport transport { _transport = _transport ?? GetComponent(); if (_transport == null) - logger.LogWarning("Insight has no Transport component. Networking won't work without a Transport"); + Debug.LogWarning("Insight has no Transport component. Networking won't work without a Transport"); return _transport; } } @@ -59,7 +57,7 @@ public void RegisterHandler(InsightNetworkMessageDelegate handler) int msgType = GetId(); if (messageHandlers.ContainsKey(msgType)) { - logger.Log("NetworkConnection.RegisterHandler replacing " + msgType); + Debug.Log("NetworkConnection.RegisterHandler replacing " + msgType); } messageHandlers[msgType] = handler; } diff --git a/Assets/Insight/InsightNetworkConnection.cs b/Assets/Insight/InsightNetworkConnection.cs index d64c72b..d1f4ca3 100644 --- a/Assets/Insight/InsightNetworkConnection.cs +++ b/Assets/Insight/InsightNetworkConnection.cs @@ -7,8 +7,6 @@ namespace Insight { public class InsightNetworkConnection : IDisposable { - static readonly ILogger logger = LogFactory.GetLogger(typeof(InsightNetworkConnection)); - Dictionary m_MessageHandlers; public int hostId = -1; @@ -84,7 +82,7 @@ public bool InvokeHandler(short msgType, NetworkReader reader) msgDelegate(message); return true; } - logger.LogError("NetworkConnection InvokeHandler no handler for " + msgType); + Debug.LogError("NetworkConnection InvokeHandler no handler for " + msgType); return false; } @@ -103,7 +101,7 @@ public void RegisterHandler(short msgType, InsightNetworkMessageDelegate handler { if (m_MessageHandlers.ContainsKey(msgType)) { - logger.Log("NetworkConnection.RegisterHandler replacing " + msgType); + Debug.Log("NetworkConnection.RegisterHandler replacing " + msgType); } m_MessageHandlers[msgType] = handler; } @@ -125,14 +123,14 @@ protected virtual bool SendBytes(byte[] bytes) //Currently no support for transport channels in Insight. if (bytes.Length > GetActiveInsight().transport.GetMaxPacketSize(0)) { - logger.LogError("NetworkConnection:SendBytes cannot send packet larger than " + int.MaxValue + " bytes"); + Debug.LogError("NetworkConnection:SendBytes cannot send packet larger than " + int.MaxValue + " bytes"); return false; } if (bytes.Length == 0) { // zero length packets getting into the packet queues are bad. - logger.LogError("NetworkConnection:SendBytes cannot send zero bytes"); + Debug.LogError("NetworkConnection:SendBytes cannot send zero bytes"); return false; } @@ -146,7 +144,7 @@ public virtual void TransportReceive(ArraySegment data) if (GetActiveInsight().UnpackMessage(reader, out int msgType)) { - logger.Log("ConnectionRecv " + this + " msgType:" + msgType + " content:" + BitConverter.ToString(data.Array, data.Offset, data.Count)); + Debug.Log("ConnectionRecv " + this + " msgType:" + msgType + " content:" + BitConverter.ToString(data.Array, data.Offset, data.Count)); int callbackId = reader.ReadInt32(); @@ -167,7 +165,7 @@ public virtual void TransportReceive(ArraySegment data) else { //NOTE: this throws away the rest of the buffer. Need moar error codes - logger.LogError("Unknown message ID " + msgType + " connId:" + connectionId); + Debug.LogError("Unknown message ID " + msgType + " connId:" + connectionId); } } diff --git a/Assets/Insight/InsightServer.cs b/Assets/Insight/InsightServer.cs index f21aa09..c3cbc70 100644 --- a/Assets/Insight/InsightServer.cs +++ b/Assets/Insight/InsightServer.cs @@ -7,8 +7,6 @@ namespace Insight { public class InsightServer : InsightCommon { - static readonly ILogger logger = LogFactory.GetLogger(typeof(InsightServer)); - protected int serverHostId = -1; //-1 = never connected, 0 = disconnected, 1 = connected protected Dictionary connections = new Dictionary(); protected List sendToAllFinishedCallbacks = new List(); @@ -40,7 +38,7 @@ public virtual void Update() public override void StartInsight() { - logger.Log("[InsightServer] - Start"); + Debug.Log("[InsightServer] - Start"); transport.ServerStart(); serverHostId = 0; @@ -64,7 +62,7 @@ public override void StopInsight() void HandleConnect(int connectionId) { - logger.Log("[InsightServer] - Client connected connectionID: " + connectionId, this); + Debug.Log("[InsightServer] - Client connected connectionID: " + connectionId, this); // get ip address from connection string address = GetConnectionInfo(connectionId); @@ -77,7 +75,7 @@ void HandleConnect(int connectionId) void HandleDisconnect(int connectionId) { - logger.Log("[InsightServer] - Client disconnected connectionID: " + connectionId, this); + Debug.Log("[InsightServer] - Client disconnected connectionID: " + connectionId, this); InsightNetworkConnection conn; if (connections.TryGetValue(connectionId, out conn)) @@ -95,7 +93,7 @@ void HandleData(int connectionId, ArraySegment data, int i) InsightNetworkConnection insightNetworkConnection; if (!connections.TryGetValue(connectionId, out insightNetworkConnection)) { - logger.LogError("HandleData: Unknown connectionId: " + connectionId, this); + Debug.LogError("HandleData: Unknown connectionId: " + connectionId, this); return; } @@ -116,7 +114,7 @@ void HandleData(int connectionId, ArraySegment data, int i) void OnError(int connectionId, Exception exception) { // TODO Let's discuss how we will handle errors - logger.LogException(exception); + Debug.LogException(exception); } public string GetConnectionInfo(int connectionId) @@ -173,7 +171,7 @@ public bool SendToClient(int connectionId, T msg, CallbackHandler callback = return connections[connectionId].Send(writer.ToArray()); } - logger.LogError("Server.Send: not connected!", this); + Debug.LogError("Server.Send: not connected!", this); return false; } @@ -189,7 +187,7 @@ public bool SendToClient(int connectionId, byte[] data) transport.ServerSend(connectionId, 0, new ArraySegment(data)); return true; } - logger.LogError("Server.Send: not connected!", this); + Debug.LogError("Server.Send: not connected!", this); return false; } @@ -215,7 +213,7 @@ public bool SendToAll(T msg, CallbackHandler callback, SendToAllFinishedCallb } return true; } - logger.LogError("Server.Send: not connected!", this); + Debug.LogError("Server.Send: not connected!", this); return false; } @@ -239,13 +237,13 @@ public bool SendToAll(byte[] bytes) } return true; } - logger.LogError("Server.Send: not connected!", this); + Debug.LogError("Server.Send: not connected!", this); return false; } void OnApplicationQuit() { - logger.Log("[InsightServer] Stopping Server"); + Debug.Log("[InsightServer] Stopping Server"); transport.ServerStop(); } @@ -280,12 +278,12 @@ protected override void CheckCallbackTimeouts() ////----------virtual handlers--------------// public virtual void OnStartInsight() { - logger.Log("[InsightServer] - Server started listening"); + Debug.Log("[InsightServer] - Server started listening"); } public virtual void OnStopInsight() { - logger.Log("[InsightServer] - Server stopping"); + Debug.Log("[InsightServer] - Server stopping"); } } } diff --git a/Assets/Insight/Modules/Chat/ChatClient.cs b/Assets/Insight/Modules/Chat/ChatClient.cs index 64593da..5ce4d2b 100644 --- a/Assets/Insight/Modules/Chat/ChatClient.cs +++ b/Assets/Insight/Modules/Chat/ChatClient.cs @@ -4,8 +4,6 @@ public class ChatClient : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ChatClient)); - InsightClient client; //Used in Example Scene: @@ -25,7 +23,7 @@ void RegisterHandlers() public void HandleChatMsg(InsightNetworkMessage netMsg) { - logger.Log("[InsightClient] - HandleChatMsg()"); + Debug.Log("[InsightClient] - HandleChatMsg()"); ChatMsg message = netMsg.ReadMessage(); diff --git a/Assets/Insight/Modules/Chat/ChatServer.cs b/Assets/Insight/Modules/Chat/ChatServer.cs index aad7bcf..ec077b6 100644 --- a/Assets/Insight/Modules/Chat/ChatServer.cs +++ b/Assets/Insight/Modules/Chat/ChatServer.cs @@ -5,8 +5,6 @@ namespace Insight { public class ChatServer : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ChatServer)); - InsightServer server; ServerAuthentication authModule; @@ -33,7 +31,7 @@ void RegisterHandlers() void HandleChatMsg(InsightNetworkMessage netMsg) { - logger.Log("[ChatServer] - Received Chat Message."); + Debug.Log("[ChatServer] - Received Chat Message."); ChatMsg message = netMsg.ReadMessage(); diff --git a/Assets/Insight/Modules/GameManager/ClientGameManager.cs b/Assets/Insight/Modules/GameManager/ClientGameManager.cs index c728137..7ad0fce 100644 --- a/Assets/Insight/Modules/GameManager/ClientGameManager.cs +++ b/Assets/Insight/Modules/GameManager/ClientGameManager.cs @@ -7,8 +7,6 @@ namespace Insight { public class ClientGameManager : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ClientGameManager)); - InsightClient client; Transport networkManagerTransport; @@ -33,7 +31,7 @@ void HandleChangeServersMsg(InsightNetworkMessage netMsg) { ChangeServerMsg message = netMsg.ReadMessage(); - logger.Log("[InsightClient] - Connecting to GameServer: " + message.NetworkAddress + ":" + message.NetworkPort + "/" + message.SceneName); + Debug.Log("[InsightClient] - Connecting to GameServer: " + message.NetworkAddress + ":" + message.NetworkPort + "/" + message.SceneName); if(networkManagerTransport.GetType().GetField("port") != null) { networkManagerTransport.GetType().GetField("port").SetValue(networkManagerTransport, message.NetworkPort); @@ -54,13 +52,13 @@ void HandleGameListMsg(InsightNetworkMessage netMsg) { GameListMsg message = netMsg.ReadMessage(); - logger.Log("[InsightClient] - Received Games List"); + Debug.Log("[InsightClient] - Received Games List"); gamesList.Clear(); foreach (GameContainer game in message.gamesArray) { - logger.Log(game.SceneName); + Debug.Log(game.SceneName); gamesList.Add(new GameContainer() { diff --git a/Assets/Insight/Modules/GameManager/GameRegistration.cs b/Assets/Insight/Modules/GameManager/GameRegistration.cs index 04c70fd..6606848 100644 --- a/Assets/Insight/Modules/GameManager/GameRegistration.cs +++ b/Assets/Insight/Modules/GameManager/GameRegistration.cs @@ -6,8 +6,6 @@ namespace Insight { public class GameRegistration : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(GameRegistration)); - InsightClient client; Transport networkManagerTransport; @@ -41,13 +39,13 @@ void GatherCmdArgs() InsightArgs args = new InsightArgs(); if (args.IsProvided("-NetworkAddress")) { - logger.Log("[Args] - NetworkAddress: " + args.NetworkAddress); + Debug.Log("[Args] - NetworkAddress: " + args.NetworkAddress); NetworkAddress = args.NetworkAddress; } if (args.IsProvided("-NetworkPort")) { - logger.Log("[Args] - NetworkPort: " + args.NetworkPort); + Debug.Log("[Args] - NetworkPort: " + args.NetworkPort); NetworkPort = (ushort)args.NetworkPort; if(networkManagerTransport.GetType().GetField("port") != null) { @@ -63,14 +61,14 @@ void GatherCmdArgs() if (args.IsProvided("-SceneName")) { - logger.Log("[Args] - SceneName: " + args.SceneName); + Debug.Log("[Args] - SceneName: " + args.SceneName); GameScene = args.SceneName; SceneManager.LoadScene(args.SceneName); } if (args.IsProvided("-UniqueID")) { - logger.Log("[Args] - UniqueID: " + args.UniqueID); + Debug.Log("[Args] - UniqueID: " + args.UniqueID); UniqueID = args.UniqueID; } @@ -82,7 +80,7 @@ void GatherCmdArgs() void SendGameRegistrationToGameManager() { - logger.Log("[GameRegistration] - registering with master"); + Debug.Log("[GameRegistration] - registering with master"); client.Send(new RegisterGameMsg() { NetworkAddress = NetworkAddress, @@ -99,7 +97,7 @@ void SendGameStatusToGameManager() //Update with current values from NetworkManager: CurrentPlayers = NetworkManager.singleton.numPlayers; - logger.Log("[GameRegistration] - status update"); + Debug.Log("[GameRegistration] - status update"); client.Send(new GameStatusMsg() { UniqueID = UniqueID, diff --git a/Assets/Insight/Modules/GameManager/ServerGameManager.cs b/Assets/Insight/Modules/GameManager/ServerGameManager.cs index 11e6036..a831063 100644 --- a/Assets/Insight/Modules/GameManager/ServerGameManager.cs +++ b/Assets/Insight/Modules/GameManager/ServerGameManager.cs @@ -7,8 +7,6 @@ namespace Insight { public class ServerGameManager : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ServerGameManager)); - InsightServer server; MasterSpawner masterSpawner; @@ -40,7 +38,7 @@ void HandleRegisterGameMsg(InsightNetworkMessage netMsg) { RegisterGameMsg message = netMsg.ReadMessage(); - logger.Log("[GameManager] - Received GameRegistration request"); + Debug.Log("[GameManager] - Received GameRegistration request"); registeredGameServers.Add(new GameContainer() { @@ -59,7 +57,7 @@ void HandleGameStatusMsg(InsightNetworkMessage netMsg) { GameStatusMsg message = netMsg.ReadMessage(); - logger.Log("[GameManager] - Received Game status update"); + Debug.Log("[GameManager] - Received Game status update"); foreach (GameContainer game in registeredGameServers) { @@ -85,7 +83,7 @@ void HandleDisconnect(int connectionId) void HandleGameListMsg(InsightNetworkMessage netMsg) { - logger.Log("[MatchMaking] - Player Requesting Match list"); + Debug.Log("[MatchMaking] - Player Requesting Match list"); GameListMsg gamesListMsg = new GameListMsg(); gamesListMsg.Load(registeredGameServers); @@ -97,7 +95,7 @@ void HandleJoinGameMsg(InsightNetworkMessage netMsg) { JoinGameMsg message = netMsg.ReadMessage(); - logger.Log("[MatchMaking] - Player joining Match."); + Debug.Log("[MatchMaking] - Player joining Match."); GameContainer game = GetGameByUniqueID(message.UniqueID); diff --git a/Assets/Insight/Modules/InsightModule.cs b/Assets/Insight/Modules/InsightModule.cs index 5b000f2..e6ef1b7 100644 --- a/Assets/Insight/Modules/InsightModule.cs +++ b/Assets/Insight/Modules/InsightModule.cs @@ -16,8 +16,6 @@ public interface IServerModule public abstract class InsightModule : MonoBehaviour, IServerModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(InsightModule)); - private static Dictionary _instances; private readonly List _dependencies = new List(); @@ -41,11 +39,11 @@ public IEnumerable OptionalDependencies /// public virtual void Initialize(InsightServer server, ModuleManager manager) { - logger.LogWarning("[Module Manager] Initialize InsightServer not found for module"); + Debug.LogWarning("[Module Manager] Initialize InsightServer not found for module"); } public virtual void Initialize(InsightClient client, ModuleManager manager) { - logger.LogWarning("[Module Manager] Initialize InsightClient not found for module"); + Debug.LogWarning("[Module Manager] Initialize InsightClient not found for module"); } public virtual void Initialize(InsightCommon insight, ModuleManager manager) { diff --git a/Assets/Insight/Modules/Login/ClientAuthentication.cs b/Assets/Insight/Modules/Login/ClientAuthentication.cs index c8ee1c7..e011538 100644 --- a/Assets/Insight/Modules/Login/ClientAuthentication.cs +++ b/Assets/Insight/Modules/Login/ClientAuthentication.cs @@ -7,8 +7,6 @@ namespace Insight { public class ClientAuthentication : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ClientAuthentication)); - InsightClient client; public string uniqueID; @@ -40,15 +38,15 @@ public void SendLoginMsg(string username, string password) uniqueID = msg.UniqueID; loginSucessful = true; loginResponse = "Login Successful!"; - logger.Log("[ClientAuthentication] - Login Successful!"); + Debug.Log("[ClientAuthentication] - Login Successful!"); } if (msg.Status == CallbackStatus.Error) { - logger.LogError("[ClientAuthentication] - Callback Error: Login error"); + Debug.LogError("[ClientAuthentication] - Callback Error: Login error"); } if (msg.Status == CallbackStatus.Timeout) { - logger.LogError("[ClientAuthentication] - Callback Error: Login attempt timed out"); + Debug.LogError("[ClientAuthentication] - Callback Error: Login attempt timed out"); } }); } diff --git a/Assets/Insight/Modules/Login/ServerAuthentication.cs b/Assets/Insight/Modules/Login/ServerAuthentication.cs index 1203199..7fb0a74 100644 --- a/Assets/Insight/Modules/Login/ServerAuthentication.cs +++ b/Assets/Insight/Modules/Login/ServerAuthentication.cs @@ -7,8 +7,6 @@ namespace Insight { public class ServerAuthentication : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ServerAuthentication)); - public bool EnforceAuthentication; //Only enabled on the 'Login' example for ease of use of other examples. InsightServer server; @@ -35,7 +33,7 @@ void HandleLoginMsg(InsightNetworkMessage netMsg) { LoginMsg message = netMsg.ReadMessage(); - logger.Log("[ServerAuthentication] - Login Received: " + message.AccountName + " / " + message.AccountPassword); + Debug.Log("[ServerAuthentication] - Login Received: " + message.AccountName + " / " + message.AccountPassword); if(EnforceAuthentication) { diff --git a/Assets/Insight/Modules/Master/MasterSpawner.cs b/Assets/Insight/Modules/Master/MasterSpawner.cs index 54e9bcf..f5ef447 100644 --- a/Assets/Insight/Modules/Master/MasterSpawner.cs +++ b/Assets/Insight/Modules/Master/MasterSpawner.cs @@ -8,8 +8,6 @@ namespace Insight { public class MasterSpawner : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(MasterSpawner)); - InsightServer server; public List registeredSpawners = new List(); @@ -54,7 +52,7 @@ void HandleRegisterSpawnerMsg(InsightNetworkMessage netMsg) MaxThreads = message.MaxThreads }); - logger.Log("[MasterSpawner] - New Process Spawner Regsitered"); + Debug.Log("[MasterSpawner] - New Process Spawner Regsitered"); } //Instead of handling the msg here we will forward it to an available spawner. @@ -62,7 +60,7 @@ void HandleSpawnRequestMsg(InsightNetworkMessage netMsg) { if(registeredSpawners.Count == 0) { - logger.LogWarning("[MasterSpawner] - No Spawner Regsitered To Handle Spawn Request"); + Debug.LogWarning("[MasterSpawner] - No Spawner Regsitered To Handle Spawn Request"); return; } @@ -86,7 +84,7 @@ void HandleSpawnRequestMsg(InsightNetworkMessage netMsg) if (callbackResponse.Status == CallbackStatus.Success) { - logger.Log("[Spawn Callback] Game Created on Child Spawner: " + callbackResponse.UniqueID); + Debug.Log("[Spawn Callback] Game Created on Child Spawner: " + callbackResponse.UniqueID); //If callback from original message is present if (netMsg.callbackId != 0) @@ -96,11 +94,11 @@ void HandleSpawnRequestMsg(InsightNetworkMessage netMsg) } if (callbackResponse.Status == CallbackStatus.Timeout) { - logger.Log("[Spawn Callback] Createion Timed Out: " + callbackResponse.UniqueID); + Debug.Log("[Spawn Callback] Createion Timed Out: " + callbackResponse.UniqueID); } if (callbackResponse.Status == CallbackStatus.Error) { - logger.Log("[Spawn Callback] Error in SpawnRequest."); + Debug.Log("[Spawn Callback] Error in SpawnRequest."); } }); } @@ -122,7 +120,7 @@ public void InternalSpawnRequest(RequestSpawnStartMsg message) { if(registeredSpawners.Count == 0) { - logger.LogWarning("[MasterSpawner] - No Spawner Regsitered To Handle Internal Spawn Request"); + Debug.LogWarning("[MasterSpawner] - No Spawner Regsitered To Handle Internal Spawn Request"); return; } @@ -131,7 +129,7 @@ public void InternalSpawnRequest(RequestSpawnStartMsg message) if (freeSlotSpawners.Count == 0) { - logger.LogError("[MasterSpawner] - No Spawners with slots free available to service SpawnRequest."); + Debug.LogError("[MasterSpawner] - No Spawners with slots free available to service SpawnRequest."); return; } diff --git a/Assets/Insight/Modules/MatchMaking/ServerMatchMaking.cs b/Assets/Insight/Modules/MatchMaking/ServerMatchMaking.cs index 36547a4..956fbcd 100644 --- a/Assets/Insight/Modules/MatchMaking/ServerMatchMaking.cs +++ b/Assets/Insight/Modules/MatchMaking/ServerMatchMaking.cs @@ -9,7 +9,7 @@ namespace Insight { public class ServerMatchMaking : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ServerMatchMaking)); + public InsightServer server; ModuleManager manager; @@ -59,7 +59,7 @@ void InvokedUpdate() void HandleStartMatchSearchMsg(InsightNetworkMessage netMsg) { - logger.Log("[MatchMaking] - Player joining MatchMaking."); + Debug.Log("[MatchMaking] - Player joining MatchMaking."); playerQueue.Add(authModule.GetUserByConnection(netMsg.connectionId)); } @@ -80,13 +80,13 @@ void UpdateQueue() { if (playerQueue.Count < MinimumPlayersForGame) { - logger.Log("[MatchMaking] - Minimum players in queue not reached."); + Debug.Log("[MatchMaking] - Minimum players in queue not reached."); return; } if (masterSpawner.registeredSpawners.Count == 0) { - logger.Log("[MatchMaking] - No spawners for players in queue."); + Debug.Log("[MatchMaking] - No spawners for players in queue."); return; } @@ -159,8 +159,6 @@ void UpdateMatches() [Serializable] public class MatchContainer { - static readonly ILogger logger = LogFactory.GetLogger(typeof(MatchContainer)); - public ServerMatchMaking matchModule; public GameContainer MatchServer; public List matchUsers; @@ -210,7 +208,7 @@ bool IsSpawnServerActive() CancelMatch(); } - logger.Log("Server not active at this time"); + Debug.Log("Server not active at this time"); return false; } return true; @@ -231,7 +229,7 @@ void MovePlayersToServer() void CancelMatch() { - logger.LogError("Server failed to start within timoue period. Cancelling match."); + Debug.LogError("Server failed to start within timoue period. Cancelling match."); //TODO: Destroy the match process somewhere: MatchServer diff --git a/Assets/Insight/Modules/ModuleManager.cs b/Assets/Insight/Modules/ModuleManager.cs index f2c6d98..a8ad2a4 100644 --- a/Assets/Insight/Modules/ModuleManager.cs +++ b/Assets/Insight/Modules/ModuleManager.cs @@ -9,8 +9,6 @@ namespace Insight [RequireComponent(typeof(InsightCommon))] public class ModuleManager : MonoBehaviour { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ModuleManager)); - InsightClient client; InsightServer server; @@ -122,12 +120,12 @@ public bool InitializeModules(InsightClient client, InsightServer server) if (server) { entry.Value.Initialize(server, this); - logger.LogWarning("[" + gameObject.name + "] Loaded InsightServer Module: " + entry.Key.ToString()); + Debug.LogWarning("[" + gameObject.name + "] Loaded InsightServer Module: " + entry.Key.ToString()); } if (client) { entry.Value.Initialize(client, this); - logger.LogWarning("[" + gameObject.name + "] Loaded InsightClient Module: " + entry.Key.ToString()); + Debug.LogWarning("[" + gameObject.name + "] Loaded InsightClient Module: " + entry.Key.ToString()); } //Add the new module to the HashSet diff --git a/Assets/Insight/Modules/Spawner/ProcessSpawner.cs b/Assets/Insight/Modules/Spawner/ProcessSpawner.cs index b6d1c4a..30e301e 100644 --- a/Assets/Insight/Modules/Spawner/ProcessSpawner.cs +++ b/Assets/Insight/Modules/Spawner/ProcessSpawner.cs @@ -3,13 +3,12 @@ using System.Diagnostics; using System.Linq; using UnityEngine; +using Debug = UnityEngine.Debug; namespace Insight { public class ProcessSpawner : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ProcessSpawner)); - [HideInInspector] public InsightServer server; [HideInInspector] public InsightClient client; @@ -109,7 +108,7 @@ void RegisterToMaster() { if (client.isConnected) { - logger.LogWarning("[ProcessSpawner] - Registering to Master"); + Debug.LogWarning("[ProcessSpawner] - Registering to Master"); client.Send(new RegisterSpawnerMsg() { UniqueID = "", //Can provide a password to authenticate to the master as a trusted spawner @@ -132,7 +131,7 @@ void CheckSpawnedProcessHealth() if (spawnerProcesses[i].process.HasExited) { - logger.Log("Removing process that has exited"); + Debug.Log("Removing process that has exited"); spawnerProcesses[i].process = null; spawnerProcesses[i].pid = 0; spawnerProcesses[i].uniqueID = ""; @@ -180,7 +179,7 @@ bool InternalStartNewProcess(RequestSpawnStartMsg spawnProperties) { spawnProperties.UniqueID = Guid.NewGuid().ToString(); - logger.LogWarning("[ProcessSpawner] - UniqueID was not provided for spawn. Generating: " + spawnProperties.UniqueID); + Debug.LogWarning("[ProcessSpawner] - UniqueID was not provided for spawn. Generating: " + spawnProperties.UniqueID); } Process p = new Process(); @@ -197,11 +196,11 @@ bool InternalStartNewProcess(RequestSpawnStartMsg spawnProperties) if (p.Start()) { - logger.Log("[ProcessSpawner]: spawning: " + p.StartInfo.FileName + "; args=" + p.StartInfo.Arguments); + Debug.Log("[ProcessSpawner]: spawning: " + p.StartInfo.FileName + "; args=" + p.StartInfo.Arguments); } else { - logger.LogError("[ProcessSpawner] - Process Creation Failed."); + Debug.LogError("[ProcessSpawner] - Process Creation Failed."); return false; } @@ -233,7 +232,7 @@ int GetPort() } } - logger.LogError("[ProcessSpawner] - Maximum Process Count Reached"); + Debug.LogError("[ProcessSpawner] - Maximum Process Count Reached"); return -1; } diff --git a/Assets/Insight/Modules/Spawner/ServerIdler.cs b/Assets/Insight/Modules/Spawner/ServerIdler.cs index a3e9ac7..1e22e97 100644 --- a/Assets/Insight/Modules/Spawner/ServerIdler.cs +++ b/Assets/Insight/Modules/Spawner/ServerIdler.cs @@ -5,8 +5,6 @@ namespace Insight { public class ServerIdler : InsightModule { - static readonly ILogger logger = LogFactory.GetLogger(typeof(ServerIdler)); - public int MaxMinutesOfIdle; public override void Initialize(InsightClient insight, ModuleManager manager) @@ -22,7 +20,7 @@ void UpdateIdleState() //Cancel if players connect to the game. if(NetworkManager.singleton.numPlayers == 0) { - logger.LogWarning("[ServerIdler] - No players connected within the allowed time. Shutting down server"); + Debug.LogWarning("[ServerIdler] - No players connected within the allowed time. Shutting down server"); NetworkManager.singleton.StopServer();