cobalt-rs
cobalt-rs copied to clipboard
Better control over instant queue needed.
In current cobalt, instant messages are put in a queue and guaranteed to be given to the OS at some point, even when being rate limited due to a congested state.
This is probably a good default behavior, but for example in multiplayer game networking, it is not unusual to have types of messages where newer ones completely supersede older ones and keeping obsolete messages around to send them later is actually harmful.
One way to better support this use case would be to add another MessageKind
which acts like Instant
, except that all messages of this kind are cleared from the message queue after each call to Connection::send_packet
.
Another, somewhat lower level, way would be to allow the application to attach some kind of application defined type id (maybe just an u8
or u32
) to each (Instant) message and have a method to remove all messages of a certain type from the message queue.
Or you could have a new MessageQueueFilter
type parameter on Connection, which also defines some kind of meta data to be attached to each message and has a filter method to decide whether to drop a message from the queue. This is of course a major change and might not be the best idea. This would however allow applications to, for example, drop messages if they aren't sent out within a certain time frame.