Add a simple message counter to stop lag from repeating messages
Discord has a bad habit of multiplying messages at times, this is due to network related issues.
A simple, crude and highly effective solution is for the client to also send a small variable with the message.
This could be an 8 bit value, 0-255.
It increments every time the client sends a new message.
This means, if a message were to get multiplied due to network related issues, then discord would get 2-3 or more messages having the same value, thereby Discord knows that the client only sent 1 message and can thereby ignore the rest.
The server keeps the value of the last message in memory. And will simply ignore all message having this value. (The server could store the last 2-3 values, since network lag can get rather bad at times.)
A timeout on the counter can ensure that both client and server does not collide, so that the server doesn't ignore messages at the start of communication.
The client can technically start at any arbitrarily selected number if the server starts at undefined, and also times out to undefined.
Otherwise the client needs to start at some predetermined value (like 0), as well as the server starting at some offset from that value. (preferably as far away as possible, like 255) Downside with this later solution is that the server and client can collide if a timeout on either side occurs. Since the client never sends "undefined" as a value, nor is the server in this case ever having "undefined" in memory either, and this opens the door to collisions.
-
In my experienced, even Skype does this in some way.
1
Yorum yazmak için lütfen oturum açın.
Yorumlar
1 yorum