This UDP mode is called ‘per client,
per operation’.
The number for this UDP mode (to be used
with mnStartServer and mnGetUDPMode) is 2. C++ users can use the constant
UM_PER_CLIENT_PER_OPERATION instead.
In this UDP mode, data is collected on
a per client and per operation basis. As the name suggests, this mode
is similar to the UM_PER_CLIENT mode, but with the introduction of the
operation system.
What if you want to send multiple different
types of packets, rather than one single packet? In UM_PER_CLIENT mode
only one type of packet is permitted; otherwise one type of packet may
overwrite another type which would mean that packets are wrongly being
dropped.
E.g. Lets imagine a system that you are
working on. Your system involves two types of UDP packets: one that
contains player 3D positions and one that contains player 3D angles.
Under UM_PER_CLIENT mode you would have to combine these into one single
packet. Using UM_PER_CLIENT_PER_OPERATION you can assign a different
operation ID to each type of packet. So, positions can have an ID of
0 and rotations can have an ID of 1; this is their operation ID. DarkNet
uses these ID to prevent different IDs from overwriting each other.
This means that old packets for a client are discarded only when a new
packet for that same client and same operation is received.
In UM_PER_CLIENT_PER_OPERATION mode the
operation parameter and the client parameter of mnRecvUDP are relevant
on both the client and the server side.
There is a prefix of one unsigned integer
added silently (you do not need to deal with it) to all outgoing UDP
packets which is used to determine the age of a packet. The integer
is the length of time in milliseconds that your application has been
running for. You can use mnGetUDPClock to retrieve this integer.
The client must add the following to the start of each packet that it sends to the server:
| Data Type | Data Description |
| Integer | Operation ID of the packet. This is
used by your application to determine what the packet should be used
for and used by DarkNet to determine what it should overwrite, if anything. This integer is not received by the server
and is removed by DarkNet; the remainder of the packet is received. If the server receives a packet with an operation ID that is too high or low to be valid, the client is automatically dropped. Operation ID’s range from 0 to one less the maximum number of operations set by mnStartServer. |
The server must add the following to the start of each packet that it sends to a client in this exact order:
| Data Type | Data Description |
| Integer | Client ID of the client that this packet
is about e.g. if the packet contains the 3D position of client 5, then
this should be 5. This integer is not received by the client
and is removed by DarkNet If the client receives a client ID that
is too high or low to be valid then an error message will be displayed
(on the client side). If you want to send a packet that is not about any client, you can use a client ID of 0 which indicates that the packet is about the server. |
| Integer | Operation ID of the packet. This is
used by your application to determine what the packet should be used
for and used by DarkNet to determine what it should overwrite, if anything. The integer is not received by the client
and is removed by DarkNet; the remainder of the packet is received. If the client receives an operation ID that is too high or low to be valid then an error message will be displayed (on the client side). |