Skip to content

feat: Message Ordering #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0a4f1e6
Message ordering WIP
ShadauxCat Jun 18, 2021
6edda60
Converted all messages to the new flow, got all runtime tests passing…
ShadauxCat Jul 1, 2021
1905156
All tests fixed. Also fixed some other warnings that were being seen.
ShadauxCat Jul 1, 2021
0c34ce4
Merge branch 'develop' into feature/message_ordering. Still some fail…
ShadauxCat Jul 6, 2021
8af4b87
Fixed two major issues to correct all current tests:
ShadauxCat Jul 6, 2021
2f66fba
Fixed standards.py failures and added a warning when changing initial…
ShadauxCat Jul 7, 2021
c24834e
Address review feedback
ShadauxCat Jul 13, 2021
722b5ff
Back out accidental change to packages-lock.json
ShadauxCat Jul 13, 2021
956d996
Actually reverting packages-lock.json correctly
ShadauxCat Jul 13, 2021
d61a06e
Reverted change to .editorconfig, renamed a field in the rpc params
ShadauxCat Jul 14, 2021
c015bac
Fix naming violation
ShadauxCat Jul 15, 2021
6cc5f66
Realized MessageBatcher was bugged when sending messages on different…
ShadauxCat Jul 15, 2021
87fef25
Addressed some review feedback.
ShadauxCat Jul 21, 2021
9c279a0
Addressed some more review feedback.
ShadauxCat Jul 21, 2021
b26b8b5
Moved SpawnRpcDespawnInstanceHandler to its own file.
ShadauxCat Jul 21, 2021
f2fbd0a
Addressed further review feedback.
ShadauxCat Jul 22, 2021
6be7950
Fixed a missed rename reversion.
ShadauxCat Jul 22, 2021
c2eb4ef
Merge branch 'develop' into feature/message_ordering
ShadauxCat Jul 22, 2021
f62b3e0
Removed file that shouldn't have been committed.
ShadauxCat Jul 23, 2021
b71926b
- Removed a check for an error case that can't actually happen
ShadauxCat Jul 23, 2021
3c2176f
Fixed NetworkManagerMessageHandlerTests
ShadauxCat Jul 23, 2021
c362242
Fixed an issue created by my last change that would cause messages se…
ShadauxCat Jul 23, 2021
adb380f
Whoops, naming.
ShadauxCat Jul 23, 2021
1a58496
Increased timeout value in NetworkTransformTests
ShadauxCat Jul 23, 2021
a8e834b
Maybe set framerate back to the original value after the test, maybe …
ShadauxCat Jul 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 78 additions & 78 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,81 +24,81 @@ dotnet_style_require_accessibility_modifiers = always:error
csharp_style_var_when_type_is_apparent = true:error
csharp_prefer_braces = true:error
csharp_using_directive_placement = outside_namespace:error

# naming rules
# namespace MLAPI { ... }
# public class NetworkObject { ... }
# public void Spawn(...) { ... }
dotnet_naming_symbols.usertypes_naming_symbols.applicable_kinds = namespace, class, struct, enum, property, method, field, event, delegate, local_function
dotnet_naming_symbols.usertypes_naming_symbols.applicable_accessibilities = public, internal
dotnet_naming_style.usertypes_naming_style.capitalization = pascal_case
dotnet_naming_rule.usertypes_naming_rule.symbols = usertypes_naming_symbols
dotnet_naming_rule.usertypes_naming_rule.style = usertypes_naming_style
dotnet_naming_rule.usertypes_naming_rule.severity = error

# public void ChangeOwnership(ulong newOwnerClientId) { ... }
# ulong[] targetClientIds = clientRpcParams.Send.TargetClientIds;
dotnet_naming_symbols.paramlocal_naming_symbols.applicable_kinds = parameter, local
dotnet_naming_symbols.paramlocal_naming_symbols.applicable_accessibilities = *
dotnet_naming_style.paramlocal_naming_style.capitalization = camel_case
dotnet_naming_rule.paramlocal_naming_rule.symbols = paramlocal_naming_symbols
dotnet_naming_rule.paramlocal_naming_rule.style = paramlocal_naming_style
dotnet_naming_rule.paramlocal_naming_rule.severity = error

# interface INetworkSerializable
dotnet_naming_symbols.interface_naming_symbols.applicable_kinds = interface
dotnet_naming_symbols.interface_naming_symbols.applicable_accessibilities = public, internal
dotnet_naming_style.interface_naming_style.required_prefix = I
dotnet_naming_style.interface_naming_style.capitalization = pascal_case
dotnet_naming_rule.interface_naming_rule.symbols = interface_naming_symbols
dotnet_naming_rule.interface_naming_rule.style = interface_naming_style
dotnet_naming_rule.interface_naming_rule.severity = error

# class NetworkVariable<T>
# class NetworkDictionary<TKey, TValue>
dotnet_naming_symbols.typeparam_naming_symbols.applicable_kinds = type_parameter
dotnet_naming_symbols.typeparam_naming_symbols.applicable_accessibilities = public, internal
dotnet_naming_style.typeparam_naming_style.required_prefix = T
dotnet_naming_style.typeparam_naming_style.capitalization = pascal_case
dotnet_naming_rule.typeparam_naming_rule.symbols = typeparam_naming_symbols
dotnet_naming_rule.typeparam_naming_rule.style = typeparam_naming_style
dotnet_naming_rule.typeparam_naming_rule.severity = error

# const int k_MaxCount
dotnet_naming_symbols.constant_naming_symbols.applicable_kinds = field
dotnet_naming_symbols.constant_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.constant_naming_symbols.required_modifiers = const
dotnet_naming_style.constant_naming_style.required_prefix = k_
dotnet_naming_style.constant_naming_style.capitalization = pascal_case
dotnet_naming_rule.constant_naming_rule.symbols = constant_naming_symbols
dotnet_naming_rule.constant_naming_rule.style = constant_naming_style
dotnet_naming_rule.constant_naming_rule.severity = error

# static readonly Vector3 k_DefaultLength
dotnet_naming_symbols.staticreadonly_naming_symbols.applicable_kinds = field
dotnet_naming_symbols.staticreadonly_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.staticreadonly_naming_symbols.required_modifiers = static, readonly
dotnet_naming_style.staticreadonly_naming_style.required_prefix = k_
dotnet_naming_style.staticreadonly_naming_style.capitalization = pascal_case
dotnet_naming_rule.staticreadonly_naming_rule.symbols = staticreadonly_naming_symbols
dotnet_naming_rule.staticreadonly_naming_rule.style = staticreadonly_naming_style
dotnet_naming_rule.staticreadonly_naming_rule.severity = error

# static int s_SharedCount
dotnet_naming_symbols.staticfield_naming_symbols.applicable_kinds = field
dotnet_naming_symbols.staticfield_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.staticfield_naming_symbols.required_modifiers = static
dotnet_naming_style.staticfield_naming_style.required_prefix = s_
dotnet_naming_style.staticfield_naming_style.capitalization = pascal_case
dotnet_naming_rule.staticfield_naming_rule.symbols = staticfield_naming_symbols
dotnet_naming_rule.staticfield_naming_rule.style = staticfield_naming_style
dotnet_naming_rule.staticfield_naming_rule.severity = error

# int m_CurrentCount
dotnet_naming_symbols.memberfield_naming_symbols.applicable_kinds = field
dotnet_naming_symbols.memberfield_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_style.memberfield_naming_style.required_prefix = m_
dotnet_naming_style.memberfield_naming_style.capitalization = pascal_case
dotnet_naming_rule.memberfield_naming_rule.symbols = memberfield_naming_symbols
dotnet_naming_rule.memberfield_naming_rule.style = memberfield_naming_style
dotnet_naming_rule.memberfield_naming_rule.severity = error
#
# # naming rules
# # namespace MLAPI { ... }
# # public class NetworkObject { ... }
# # public void Spawn(...) { ... }
# dotnet_naming_symbols.usertypes_naming_symbols.applicable_kinds = namespace, class, struct, enum, property, method, field, event, delegate, local_function
# dotnet_naming_symbols.usertypes_naming_symbols.applicable_accessibilities = public, internal
# dotnet_naming_style.usertypes_naming_style.capitalization = pascal_case
# dotnet_naming_rule.usertypes_naming_rule.symbols = usertypes_naming_symbols
# dotnet_naming_rule.usertypes_naming_rule.style = usertypes_naming_style
# dotnet_naming_rule.usertypes_naming_rule.severity = error
#
# # public void ChangeOwnership(ulong newOwnerClientId) { ... }
# # ulong[] targetClientIds = clientRpcParams.Send.TargetClientIds;
# dotnet_naming_symbols.paramlocal_naming_symbols.applicable_kinds = parameter, local
# dotnet_naming_symbols.paramlocal_naming_symbols.applicable_accessibilities = *
# dotnet_naming_style.paramlocal_naming_style.capitalization = camel_case
# dotnet_naming_rule.paramlocal_naming_rule.symbols = paramlocal_naming_symbols
# dotnet_naming_rule.paramlocal_naming_rule.style = paramlocal_naming_style
# dotnet_naming_rule.paramlocal_naming_rule.severity = error
#
# # interface INetworkSerializable
# dotnet_naming_symbols.interface_naming_symbols.applicable_kinds = interface
# dotnet_naming_symbols.interface_naming_symbols.applicable_accessibilities = public, internal
# dotnet_naming_style.interface_naming_style.required_prefix = I
# dotnet_naming_style.interface_naming_style.capitalization = pascal_case
# dotnet_naming_rule.interface_naming_rule.symbols = interface_naming_symbols
# dotnet_naming_rule.interface_naming_rule.style = interface_naming_style
# dotnet_naming_rule.interface_naming_rule.severity = error
#
# # class NetworkVariable<T>
# # class NetworkDictionary<TKey, TValue>
# dotnet_naming_symbols.typeparam_naming_symbols.applicable_kinds = type_parameter
# dotnet_naming_symbols.typeparam_naming_symbols.applicable_accessibilities = public, internal
# dotnet_naming_style.typeparam_naming_style.required_prefix = T
# dotnet_naming_style.typeparam_naming_style.capitalization = pascal_case
# dotnet_naming_rule.typeparam_naming_rule.symbols = typeparam_naming_symbols
# dotnet_naming_rule.typeparam_naming_rule.style = typeparam_naming_style
# dotnet_naming_rule.typeparam_naming_rule.severity = error
#
# # const int k_MaxCount
# dotnet_naming_symbols.constant_naming_symbols.applicable_kinds = field
# dotnet_naming_symbols.constant_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
# dotnet_naming_symbols.constant_naming_symbols.required_modifiers = const
# dotnet_naming_style.constant_naming_style.required_prefix = k_
# dotnet_naming_style.constant_naming_style.capitalization = pascal_case
# dotnet_naming_rule.constant_naming_rule.symbols = constant_naming_symbols
# dotnet_naming_rule.constant_naming_rule.style = constant_naming_style
# dotnet_naming_rule.constant_naming_rule.severity = error
#
# # static readonly Vector3 k_DefaultLength
# dotnet_naming_symbols.staticreadonly_naming_symbols.applicable_kinds = field
# dotnet_naming_symbols.staticreadonly_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
# dotnet_naming_symbols.staticreadonly_naming_symbols.required_modifiers = static, readonly
# dotnet_naming_style.staticreadonly_naming_style.required_prefix = k_
# dotnet_naming_style.staticreadonly_naming_style.capitalization = pascal_case
# dotnet_naming_rule.staticreadonly_naming_rule.symbols = staticreadonly_naming_symbols
# dotnet_naming_rule.staticreadonly_naming_rule.style = staticreadonly_naming_style
# dotnet_naming_rule.staticreadonly_naming_rule.severity = error
#
# # static int s_SharedCount
# dotnet_naming_symbols.staticfield_naming_symbols.applicable_kinds = field
# dotnet_naming_symbols.staticfield_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
# dotnet_naming_symbols.staticfield_naming_symbols.required_modifiers = static
# dotnet_naming_style.staticfield_naming_style.required_prefix = s_
# dotnet_naming_style.staticfield_naming_style.capitalization = pascal_case
# dotnet_naming_rule.staticfield_naming_rule.symbols = staticfield_naming_symbols
# dotnet_naming_rule.staticfield_naming_rule.style = staticfield_naming_style
# dotnet_naming_rule.staticfield_naming_rule.severity = error
#
# # int m_CurrentCount
# dotnet_naming_symbols.memberfield_naming_symbols.applicable_kinds = field
# dotnet_naming_symbols.memberfield_naming_symbols.applicable_accessibilities = private, protected, protected_internal, private_protected
# dotnet_naming_style.memberfield_naming_style.required_prefix = m_
# dotnet_naming_style.memberfield_naming_style.capitalization = pascal_case
# dotnet_naming_rule.memberfield_naming_rule.symbols = memberfield_naming_symbols
# dotnet_naming_rule.memberfield_naming_rule.style = memberfield_naming_style
# dotnet_naming_rule.memberfield_naming_rule.severity = error
14 changes: 7 additions & 7 deletions com.unity.multiplayer.mlapi/Editor/MLAPIProfilerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ private class MLAPIModules

private static List<MLAPIProfilerCounter> CreateRPCCounters() => new List<MLAPIProfilerCounter>()
{
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcBatchesSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcBatchesReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcQueueProcessed, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcInQueueSize, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.RpcOutQueueSize, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessagesSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessagesReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessageBatchesSent, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessageBatchesReceived, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessageQueueProcessed, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessageInQueueSize, m_Category = ProfilerCategory.Network.Name },
new MLAPIProfilerCounter { m_Name = ProfilerConstants.MessageOutQueueSize, m_Category = ProfilerCategory.Network.Name },
};

private static List<MLAPIProfilerCounter> CreateOperationsCounters() => new List<MLAPIProfilerCounter>()
Expand Down
13 changes: 0 additions & 13 deletions com.unity.multiplayer.mlapi/Editor/NetworkManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public class NetworkManagerEditor : UnityEditor.Editor
private SerializedProperty m_NetworkIdRecycleDelayProperty;
private SerializedProperty m_RpcHashSizeProperty;
private SerializedProperty m_LoadSceneTimeOutProperty;
private SerializedProperty m_EnableMessageBufferingProperty;
private SerializedProperty m_MessageBufferTimeoutProperty;

private ReorderableList m_NetworkPrefabsList;
private ReorderableList m_RegisteredScenesList;
Expand Down Expand Up @@ -119,8 +117,6 @@ private void Initialize()
m_NetworkIdRecycleDelayProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkIdRecycleDelay");
m_RpcHashSizeProperty = m_NetworkConfigProperty.FindPropertyRelative("RpcHashSize");
m_LoadSceneTimeOutProperty = m_NetworkConfigProperty.FindPropertyRelative("LoadSceneTimeOut");
m_EnableMessageBufferingProperty = m_NetworkConfigProperty.FindPropertyRelative("EnableMessageBuffering");
m_MessageBufferTimeoutProperty = m_NetworkConfigProperty.FindPropertyRelative("MessageBufferTimeout");


ReloadTransports();
Expand Down Expand Up @@ -155,8 +151,6 @@ private void CheckNullProperties()
m_NetworkIdRecycleDelayProperty = m_NetworkConfigProperty.FindPropertyRelative("NetworkIdRecycleDelay");
m_RpcHashSizeProperty = m_NetworkConfigProperty.FindPropertyRelative("RpcHashSize");
m_LoadSceneTimeOutProperty = m_NetworkConfigProperty.FindPropertyRelative("LoadSceneTimeOut");
m_EnableMessageBufferingProperty = m_NetworkConfigProperty.FindPropertyRelative("EnableMessageBuffering");
m_MessageBufferTimeoutProperty = m_NetworkConfigProperty.FindPropertyRelative("MessageBufferTimeout");
}

private void OnEnable()
Expand Down Expand Up @@ -347,13 +341,6 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_NetworkIdRecycleDelayProperty);
}

EditorGUILayout.PropertyField(m_EnableMessageBufferingProperty);

using (new EditorGUI.DisabledScope(!m_NetworkManager.NetworkConfig.EnableMessageBuffering))
{
EditorGUILayout.PropertyField(m_MessageBufferTimeoutProperty);
}

EditorGUILayout.LabelField("Bandwidth", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_RpcHashSizeProperty);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ public class NetworkConfig
[Tooltip("The amount of seconds to wait for all clients to load a requested scene")]
public int LoadSceneTimeOut = 120;

/// <summary>
/// Whether or not message buffering should be enabled. This will resolve most out of order messages during spawn.
/// </summary>
[Tooltip("Whether or not message buffering should be enabled. This will resolve most out of order messages during spawn")]
public bool EnableMessageBuffering = true;

/// <summary>
/// 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.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,6 @@ namespace MLAPI.Configuration
/// </summary>
internal static class NetworkConstants
{
internal const string PROTOCOL_VERSION = "13.0.0";

internal const byte CONNECTION_REQUEST = 3;
internal const byte CONNECTION_APPROVED = 4;
internal const byte ADD_OBJECT = 5;
internal const byte DESTROY_OBJECT = 6;
internal const byte SWITCH_SCENE = 7;
internal const byte CLIENT_SWITCH_SCENE_COMPLETED = 8;
internal const byte CHANGE_OWNER = 9;
internal const byte ADD_OBJECTS = 10;
internal const byte TIME_SYNC = 11;
internal const byte NETWORK_VARIABLE_DELTA = 12;
internal const byte ALL_CLIENTS_LOADED_SCENE = 14;
internal const byte PARENT_SYNC = 16;
internal const byte UNNAMED_MESSAGE = 20;
internal const byte DESTROY_OBJECTS = 21;
internal const byte NAMED_MESSAGE = 22;
internal const byte SERVER_LOG = 23;
internal const byte SNAPSHOT_DATA = 25;
internal const byte SERVER_RPC = 30;
internal const byte CLIENT_RPC = 31;
internal const byte INVALID = 32;

internal static readonly string[] MESSAGE_NAMES =
{
"", // 0
"",
"",
"CONNECTION_REQUEST",
"CONNECTION_APPROVED",
"ADD_OBJECT",
"DESTROY_OBJECT",
"SWITCH_SCENE",
"CLIENT_SWITCH_SCENE_COMPLETED",
"CHANGE_OWNER",
"ADD_OBJECTS",
"TIME_SYNC",
"NETWORK_VARIABLE_DELTA",
"",
"ALL_CLIENTS_SWITCH_SCENE_COMPLETED",
"",
"PARENT_SYNC", // 16
"",
"",
"",
"UNNAMED_MESSAGE",
"DESTROY_OBJECTS",
"NAMED_MESSAGE",
"SERVER_LOG",
"",
"SNAPSHOT_DATA",
"",
"",
"",
"",
"SERVER_RPC",
"CLIENT_RPC",
"INVALID" // 32
};
internal const string PROTOCOL_VERSION = "14.0.0";
}
}
Loading