lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
624 stars 67 forks source link

Add Unreliable Sequenced & Reliable Unordered Channels #25

Closed sylv256 closed 1 year ago

sylv256 commented 2 years ago

For a complete game netcode, we need Unreliable Sequenced and Reliable Unordered channels.

Usecases

Unreliable Sequenced

An Unreliable Sequenced channel can be used for inputs from the client, state updates, and other packets that don't require reliability but need to be received sequentially.

Reliable Unordered

A Reliable Unordered channel can be used for particle effects and other packets that don't need to be ordered but require reliability.

Shatur commented 2 years ago

An Unreliable Sequenced channel can be used for inputs from the client, state updates, and other packets that don't require reliability but need to be received sequentially.

This is what renet actually have for unreliable channel right now.

lucaspoffo commented 2 years ago

My opinion about this:

Unreliable Sequenced: I feel this should be implemented using Unreliable channels by the user, the implementation should be simple enough - adding a sequence value to the message and checking when receiving - that can be done on the user side. Sometimes, simply dropping old messages is not enough, you might want to buffer the messages or do some custom logic. But I might be wrong and adding this could simplify some work for the user.

Reliable Unordered: this seems useful and hard to do yourself (would need to implement the Reliable channel again), I didn't add this option because of complexity, wanted to keep channels simple, and also because keeping the ordering would work anyway. Might check to see if the logic is simple enough to be an enum on the Reliable channel config.

Shatur commented 2 years ago

This is what renet actually have for unreliable channel right now.

Sorry, I read it wrong. Yes, it's not sequenced. Usually games use what @lucaspoffo is described.

lucaspoffo commented 1 year ago

Reliable unordered implemented by 6f6ddf592650c124daca66cebf394bc79a0bbebc Unreliable sequenced implemented by a415a5d542aabc2c09cb5e80c30738c787e6d672