Skip to content

refactor: NetworkMessageSystem (formerly MessagingSystem)#2505

Merged
0xFA11 merged 9 commits intodevelopfrom
refactor/messaging
Apr 12, 2023
Merged

refactor: NetworkMessageSystem (formerly MessagingSystem)#2505
0xFA11 merged 9 commits intodevelopfrom
refactor/messaging

Conversation

@0xFA11
Copy link
Copy Markdown
Contributor

@0xFA11 0xFA11 commented Apr 12, 2023

  • Rename MessagingSystem to NetworkMessageManager
  • Move NetworkMessageManager out of NetworkConnectionManager
  • Delete NetworkConnectionManager.NetworkUpdate(...) entirely by inlining it into NetworkManager.NetworkUpdate(...) (unrolling and flattening the nested flow)
  • Add "Network" prefix to some message-related types

(No need for changelog entry since all changes were internal and no publicly visible changes made)

@0xFA11 0xFA11 marked this pull request as ready for review April 12, 2023 21:39
@0xFA11 0xFA11 requested review from a team as code owners April 12, 2023 21:39
Comment on lines -38 to +70
ConnectionManager.NetworkUpdate(updateStage);
{
ConnectionManager.OnEarlyUpdate();
MessageManager.OnEarlyUpdate();
}
break;
case NetworkUpdateStage.PreUpdate:
NetworkTimeSystem.NetworkUpdate(updateStage);
{
NetworkTimeSystem.NetworkUpdate(updateStage);
}
break;
case NetworkUpdateStage.PostLateUpdate:
ConnectionManager.NetworkUpdate(updateStage);
{
// This should be invoked just prior to the MessageManager processes its outbound queue.
SceneManager.CheckForAndSendNetworkObjectSceneChanged();

// Process outbound messages
MessageManager.ProcessSendQueues();

// Metrics update needs to be driven by NetworkConnectionManager's update to assure metrics are dispatched after the send queue is processed.
MetricsManager.UpdateMetrics();

// TODO 2023-Q2: Determine a better way to handle this
NetworkObject.VerifyParentingStatus();

// This is "ok" to invoke when not processing messages since it is just cleaning up messages that never got handled within their timeout period.
DeferredMessageManager.CleanupStaleTriggers();

// TODO 2023-Q2: Determine a better way to handle this
if (m_ShuttingDown)
{
ShutdownInternal();
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment on lines -204 to -258
/// <summary>
/// ConnectionManager Internal Updates
/// </summary>
internal void NetworkUpdate(NetworkUpdateStage updateStage)
{
switch (updateStage)
{
case NetworkUpdateStage.EarlyUpdate:
{
// Exit early if we haven't started or are no longer processing messages.
if (StopProcessingMessages)
{
return;
}

OnEarlyUpdate();
MessagingSystem.OnEarlyUpdate();

break;
}
case NetworkUpdateStage.PostLateUpdate:
{
// Things that should only be invoked when we are processing messages
if (!StopProcessingMessages)
{
// This should be invoked just prior to the MessagingSystem
// processes its outbound queue.
NetworkManager.SceneManager.CheckForAndSendNetworkObjectSceneChanged();

// Process outbound messages
MessagingSystem.ProcessSendQueues();

// Metrics update needs to be driven by NetworkConnectionManager's
// update to assure metrics are dispatched after the send queue is processed.
NetworkManager.NetworkMetricsManager.UpdateMetrics();

// TODO 2023-Q2: Determine a better way to handle this
NetworkObject.VerifyParentingStatus();
}

// This is "ok" to invoke when not processing messages since it is just cleaning
// up messages that never got handled within their timeout period.
NetworkManager.DeferredMessageManager.CleanupStaleTriggers();

// TODO 2023-Q2: Determine a better way to handle this
if (NetworkManager.ShutdownInProgress)
{
NetworkManager.ShutdownInternal();
}

break;
}
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment on lines -24 to +34
internal class MessagingSystem : IDisposable
internal class NetworkMessageManager : IDisposable
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smack-Pow-Boom!
Looks super-good to me!
👍 💯

@0xFA11 0xFA11 merged commit 850c7b6 into develop Apr 12, 2023
@0xFA11 0xFA11 deleted the refactor/messaging branch April 12, 2023 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants