The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.8] - 2022-04-27 ### Changed - `unmanaged` structs are no longer universally accepted as RPC parameters because some structs (i.e., structs with pointers in them, such as `NativeList<T>`) can't be supported by the default memcpy struct serializer. Structs that are intended to be serialized across the network must add `INetworkSerializeByMemcpy` to the interface list (i.e., `struct Foo : INetworkSerializeByMemcpy`). This interface is empty and just serves to mark the struct as compatible with memcpy serialization. For external structs you can't edit, you can pass them to RPCs by wrapping them in `ForceNetworkSerializeByMemcpy<T>`. (#1901) ### Removed - Removed `SIPTransport` (#1870) - Removed `ClientNetworkTransform` from the package samples and moved to Boss Room's Utilities package which can be found [here](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs). ### Fixed - Fixed `NetworkTransform` generating false positive rotation delta checks when rolling over between 0 and 360 degrees. (#1890) - Fixed client throwing an exception if it has messages in the outbound queue when processing the `NetworkEvent.Disconnect` event and is using UTP. (#1884) - Fixed issue during client synchronization if 'ValidateSceneBeforeLoading' returned false it would halt the client synchronization process resulting in a client that was approved but not synchronized or fully connected with the server. (#1883) - Fixed an issue where UNetTransport.StartServer would return success even if the underlying transport failed to start (#854) - Passing generic types to RPCs no longer causes a native crash (#1901) - Fixed an issue where calling `Shutdown` on a `NetworkManager` that was already shut down would cause an immediate shutdown the next time it was started (basically the fix makes `Shutdown` idempotent). (#1877)
118 lines
6.2 KiB
C#
118 lines
6.2 KiB
C#
using System;
|
|
|
|
namespace Unity.Netcode
|
|
{
|
|
/// <summary>
|
|
/// Used to react to different events in the messaging system. Primary use case is for
|
|
/// collecting profiling data and metrics data. Additionally, it provides OnVerifyCanSend and OnVerifyCanReceive
|
|
/// to allow for networking implementations to put limits on when certain messages can or can't be sent or received.
|
|
/// </summary>
|
|
internal interface INetworkHooks
|
|
{
|
|
/// <summary>
|
|
/// Called before an individual message is sent.
|
|
/// </summary>
|
|
/// <param name="clientId">The destination clientId</param>
|
|
/// <param name="message">The message being sent</param>
|
|
/// <param name="delivery"></param>
|
|
void OnBeforeSendMessage<T>(ulong clientId, ref T message, NetworkDelivery delivery) where T : INetworkMessage;
|
|
|
|
/// <summary>
|
|
/// Called after an individual message is sent.
|
|
/// </summary>
|
|
/// <param name="clientId">The destination clientId</param>
|
|
/// <param name="message">The message being sent</param>
|
|
/// <param name="delivery"></param>
|
|
/// <param name="messageSizeBytes">Number of bytes in the message, not including the message header</param>
|
|
void OnAfterSendMessage<T>(ulong clientId, ref T message, NetworkDelivery delivery, int messageSizeBytes) where T : INetworkMessage;
|
|
|
|
/// <summary>
|
|
/// Called before an individual message is received.
|
|
/// </summary>
|
|
/// <param name="senderId">The source clientId</param>
|
|
/// <param name="messageType">The type of the message being sent</param>
|
|
/// <param name="messageSizeBytes">Number of bytes in the message, not including the message header</param>
|
|
void OnBeforeReceiveMessage(ulong senderId, Type messageType, int messageSizeBytes);
|
|
|
|
/// <summary>
|
|
/// Called after an individual message is received.
|
|
/// </summary>
|
|
/// <param name="senderId">The source clientId</param>
|
|
/// <param name="messageType">The type of the message being sent</param>
|
|
/// <param name="messageSizeBytes">Number of bytes in the message, not including the message header</param>
|
|
void OnAfterReceiveMessage(ulong senderId, Type messageType, int messageSizeBytes);
|
|
|
|
/// <summary>
|
|
/// Called before a batch of messages is sent
|
|
/// </summary>
|
|
/// <param name="clientId">The destination clientId</param>
|
|
/// <param name="messageCount">Number of messages in the batch</param>
|
|
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
|
|
/// <param name="delivery"></param>
|
|
void OnBeforeSendBatch(ulong clientId, int messageCount, int batchSizeInBytes, NetworkDelivery delivery);
|
|
|
|
/// <summary>
|
|
/// Called after a batch of messages is sent
|
|
/// </summary>
|
|
/// <param name="clientId">The destination clientId</param>
|
|
/// <param name="messageCount">Number of messages in the batch</param>
|
|
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
|
|
/// <param name="delivery"></param>
|
|
void OnAfterSendBatch(ulong clientId, int messageCount, int batchSizeInBytes, NetworkDelivery delivery);
|
|
|
|
/// <summary>
|
|
/// Called before a batch of messages is received
|
|
/// </summary>
|
|
/// <param name="senderId">The source clientId</param>
|
|
/// <param name="messageCount">Number of messages in the batch</param>
|
|
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
|
|
void OnBeforeReceiveBatch(ulong senderId, int messageCount, int batchSizeInBytes);
|
|
|
|
/// <summary>
|
|
/// Called after a batch of messages is received
|
|
/// </summary>
|
|
/// <param name="senderId">The source clientId</param>
|
|
/// <param name="messageCount">Number of messages in the batch</param>
|
|
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
|
|
void OnAfterReceiveBatch(ulong senderId, int messageCount, int batchSizeInBytes);
|
|
|
|
|
|
/// <summary>
|
|
/// Called before a message is sent. If this returns false, the message will be discarded.
|
|
/// </summary>
|
|
/// <param name="destinationId">The destination clientId</param>
|
|
/// <param name="messageType">The type of the message</param>
|
|
/// <param name="delivery"></param>
|
|
/// <returns></returns>
|
|
bool OnVerifyCanSend(ulong destinationId, Type messageType, NetworkDelivery delivery);
|
|
|
|
/// <summary>
|
|
/// Called before a message is received. If this returns false, the message will be discarded.
|
|
/// </summary>
|
|
/// <param name="senderId">The source clientId</param>
|
|
/// <param name="messageType">The type of the message</param>
|
|
/// <param name="messageContent">The FastBufferReader containing the message</param>
|
|
/// <param name="context">The NetworkContext the message is being processed in</param>
|
|
/// <returns></returns>
|
|
bool OnVerifyCanReceive(ulong senderId, Type messageType, FastBufferReader messageContent, ref NetworkContext context);
|
|
|
|
/// <summary>
|
|
/// Called after a message is serialized, but before it's handled.
|
|
/// Differs from OnBeforeReceiveMessage in that the actual message object is passed and can be inspected.
|
|
/// </summary>
|
|
/// <param name="message">The message object</param>
|
|
/// <param name="context">The network context the message is being ahandled in</param>
|
|
/// <typeparam name="T"></typeparam>
|
|
void OnBeforeHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;
|
|
|
|
/// <summary>
|
|
/// Called after a message is serialized and handled.
|
|
/// Differs from OnAfterReceiveMessage in that the actual message object is passed and can be inspected.
|
|
/// </summary>
|
|
/// <param name="message">The message object</param>
|
|
/// <param name="context">The network context the message is being ahandled in</param>
|
|
/// <typeparam name="T"></typeparam>
|
|
void OnAfterHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;
|
|
}
|
|
}
|