-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathINetworkHooks.cs
More file actions
117 lines (104 loc) · 6.32 KB
/
INetworkHooks.cs
File metadata and controls
117 lines (104 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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>
public 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>
public 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>
public 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>
public 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>
public 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>
public 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>
public 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>
public 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>
public 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>
public 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>
public 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>
public void OnAfterHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;
}
}