Skip to content

Commit 9854c6f

Browse files
committed
feat: Added NetworkLog
BREAKING CHANGE: Removes the old LogHelper
1 parent 2058555 commit 9854c6f

24 files changed

+305
-195
lines changed

MLAPI/Configuration/MLAPIConstants.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace MLAPI.Configuration
55
/// </summary>
66
internal static class MLAPIConstants
77
{
8-
internal const string MLAPI_PROTOCOL_VERSION = "10.7.0";
8+
internal const string MLAPI_PROTOCOL_VERSION = "12.0.0";
99

1010
internal const byte MLAPI_CERTIFICATE_HAIL = 0;
1111
internal const byte MLAPI_CERTIFICATE_HAIL_RESPONSE = 1;
@@ -31,6 +31,7 @@ internal static class MLAPIConstants
3131
internal const byte MLAPI_DESTROY_OBJECTS = 21;
3232
internal const byte MLAPI_NAMED_MESSAGE = 22;
3333
internal const byte MLAPI_SYNCED_VAR = 23;
34+
internal const byte MLAPI_SERVER_LOG = 24;
3435
internal const byte INVALID = 32;
3536

3637
internal static readonly string[] MESSAGE_NAMES = {
@@ -58,7 +59,7 @@ internal static class MLAPIConstants
5859
"MLAPI_DESTROY_OBJECTS",
5960
"MLAPI_NAMED_MESSAGE",
6061
"MLAPI_SYNCED_VAR",
61-
"",
62+
"MLAPI_SERVER_LOG",
6263
"",
6364
"",
6465
"",

MLAPI/Configuration/NetworkConfig.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ public class NetworkConfig
176176
[Tooltip("The amount of time a message should be buffered for without being consumed. If it is not consumed within this time, it will be dropped")]
177177
public float MessageBufferTimeout = 20f;
178178
/// <summary>
179+
/// Whether or not to enable network logs.
180+
/// </summary>
181+
public bool EnableNetworkLogs = true;
182+
/// <summary>
179183
/// Whether or not to enable the ECDHE key exchange to allow for encryption and authentication of messages
180184
/// </summary>
181185
[Tooltip("Whether or not to enable the ECDHE key exchange to allow for encryption and authentication of messages")]
@@ -257,14 +261,15 @@ public string ToBase64()
257261
writer.WriteInt32Packed(config.LoadSceneTimeOut);
258262
writer.WriteBool(config.EnableTimeResync);
259263
writer.WriteBool(config.EnsureNetworkedVarLengthSafety);
260-
writer.WriteBits((byte)config.RpcHashSize, 3);
264+
writer.WriteBits((byte)config.RpcHashSize, 2);
261265
writer.WriteBool(ForceSamePrefabs);
262266
writer.WriteBool(UsePrefabSync);
263267
writer.WriteBool(EnableSceneManagement);
264268
writer.WriteBool(RecycleNetworkIds);
265269
writer.WriteSinglePacked(NetworkIdRecycleDelay);
266270
writer.WriteBool(EnableNetworkedVar);
267271
writer.WriteBool(AllowRuntimeSceneChanges);
272+
writer.WriteBool(EnableNetworkLogs);
268273
stream.PadStream();
269274

270275
return Convert.ToBase64String(stream.ToArray());
@@ -305,14 +310,15 @@ public void FromBase64(string base64)
305310
config.LoadSceneTimeOut = reader.ReadInt32Packed();
306311
config.EnableTimeResync = reader.ReadBool();
307312
config.EnsureNetworkedVarLengthSafety = reader.ReadBool();
308-
config.RpcHashSize = (HashSize)reader.ReadBits(3);
313+
config.RpcHashSize = (HashSize)reader.ReadBits(2);
309314
config.ForceSamePrefabs = reader.ReadBool();
310315
config.UsePrefabSync = reader.ReadBool();
311316
config.EnableSceneManagement = reader.ReadBool();
312317
config.RecycleNetworkIds = reader.ReadBool();
313318
config.NetworkIdRecycleDelay = reader.ReadSinglePacked();
314319
config.EnableNetworkedVar = reader.ReadBool();
315320
config.AllowRuntimeSceneChanges = reader.ReadBool();
321+
config.EnableNetworkLogs = reader.ReadBool();
316322
}
317323
}
318324
}
@@ -362,7 +368,7 @@ public ulong GetConfig(bool cache = true)
362368
writer.WriteBool(EnsureNetworkedVarLengthSafety);
363369
writer.WriteBool(EnableEncryption);
364370
writer.WriteBool(SignKeyExchange);
365-
writer.WriteBits((byte)RpcHashSize, 3);
371+
writer.WriteBits((byte)RpcHashSize, 2);
366372
stream.PadStream();
367373

368374
if (cache)

MLAPI/Configuration/NetworkedPrefab.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ internal ulong Hash
1616
{
1717
if (Prefab == null)
1818
{
19-
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("NetworkedPrefab is not assigned");
19+
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal) NetworkLog.LogWarning("NetworkedPrefab is not assigned");
2020
return 0;
2121
}
2222
else if (Prefab.GetComponent<NetworkedObject>() == null)
2323
{
24-
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("The NetworkedPrefab " + Prefab.name + " does not have a NetworkedObject");
24+
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal) NetworkLog.LogWarning("The NetworkedPrefab " + Prefab.name + " does not have a NetworkedObject");
2525
return 0;
2626
}
2727
else return Prefab.GetComponent<NetworkedObject>().PrefabHash;

0 commit comments

Comments
 (0)