|
SequenceChannels
There is an override for SendMessage() which takes an integer called 'sequenceChannel' - this can be used for certain delivery methods, namely UnreliableSequenced, ReliableSequenced and ReliableOrdered. The sequence channel is a number between 0 and (NetConstants.NetChannelsPerDeliveryMethod - 1) - currently 31. The reason for this limitation is to reduce the amount of overhead per message. Note that there are this amount of channels per delivery method, not in total. Messages sent in a certain sequence channel will be dropped/withheld independently of messages sent in a different sequence channel. An example: Lets say 'Health' are sent using the delivery method ReliableSequenced. This means that if a health message is delayed so that message #7 arrives AFTER message #8 has already arrived... #7 will be dropped (since #8 has already arrived with fresher information). This works well, but things is complicated if we also send 'Ammo' as ReliableSequenced. Lets say Ammo is sent in message #7 but message #8, containing 'Health' arrives before it - then #7 will be dropped for the same reasons as above. This is clearly not what we want; #7 still contains the freshest info we have on ammo. We solve this by using different sequence channels for health and ammo messages. Message numbers are individual per sequence channel, so health and ammo message cannot clash. Code: // create a message
NetOutgoingMessage om = peer.CreateMessage();
om.Write("Hello internet");
// send it as Reliable Sequenced channel number 8
peer.SendMessage(om, connection, NetDeliveryMethod.ReliableSequenced, 8);
|
► Sign in to add a comment
Hey Michael- What is the dropping behavior when multiple clients are simultaneously sending sequenced messages to the same server on the same channel?
For example, all the clients might be continuously sending their latest keyboard inputs to the server on sequence channel 8. Sequencing is useful in this case because old out-of-order messages are worthless to the server. However, I wouldn't want the server to drop Client A's input messages because Client B is sending input messages slightly faster.
It seems like each client-server connection should have its own separate logical sequence channel. Is that how Lidgren treats sequence channels?
Maybe in that case for different clients we should use different ranges of channels so they don't overlap.