-
Notifications
You must be signed in to change notification settings - Fork 450
refactor: Splitting MessagingSystem.SendMessage into a second part … #1642
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
Conversation
…alizedMessage. This allows SnapshotSystem to send larger messages, while saving an allocation and a copy.
@@ -919,8 +919,7 @@ internal void NetworkGetBehaviourVariable(UpdateCommand updateCommand, out Netwo | |||
|
|||
internal int NetworkSendMessage(SnapshotDataMessage message, ulong clientId) | |||
{ | |||
m_NetworkManager.SendMessage(ref message, NetworkDelivery.ReliableFragmentedSequenced, clientId); | |||
|
|||
m_NetworkManager.SendPreSerializedMessage(message.WriteBuffer, TotalBufferMemory, ref message, NetworkDelivery.Unreliable, clientId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This simply calls a bit further in, after tmpSerializer, because we happen to have such a FastBufferWriter ready.
@@ -352,7 +352,7 @@ private bool CanSend(ulong clientId, Type messageType, NetworkDelivery delivery) | |||
return true; | |||
} | |||
|
|||
internal unsafe int SendMessage<TMessageType, TClientIdListType>(ref TMessageType message, NetworkDelivery delivery, in TClientIdListType clientIds) | |||
internal int SendMessage<TMessageType, TClientIdListType>(ref TMessageType message, NetworkDelivery delivery, in TClientIdListType clientIds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply split the function in two parts. The first part doesn't need the unsafe
keyword anymore
@@ -426,6 +432,13 @@ private bool CanSend(ulong clientId, Type messageType, NetworkDelivery delivery) | |||
return tmpSerializer.Length + headerSerializer.Length; | |||
} | |||
|
|||
internal unsafe int SendPreSerializedMessage<TMessageType>(in FastBufferWriter tmpSerializer, int maxSize, ref TMessageType message, NetworkDelivery delivery, ulong clientId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds an entrypoint taking a single clientId
instead of a PointerListWrapper
, because that class is private.
…dPreSerializedMessage. This allows SnapshotSystem to send larger messages, while saving an allocation and a copy.
…ty-Technologies/com.unity.multiplayer.mlapi into refactor/send-message-pre-serialized
…age-pre-serialized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…1642) * Splitting MessagingSystem.SendMessage into a second part, SendPreSerializedMessage. This allows SnapshotSystem to send larger messages, while saving an allocation and a copy. * refactor: Splitting MessagingSystem.SendMessage into second part, SendPreSerializedMessage. This allows SnapshotSystem to send larger messages, while saving an allocation and a copy.
SendPreSerializedMessage. This allows SnapshotSystem to send larger messages, while saving an allocation and a copy.