Open hejiang123 opened 2 years ago
There is a term called as ["double submission"](Prevent double submission of forms in jQuery)
You need to restrict at the client side, make sure the first request send successfully and data modified, then send the second request. It means the user can not send the second request before the first request submit successfully or failed, you need to wait the result of first request.
You can also try to implement a optimistic lock, add a version number to your data. Optimistic vs. Pessimistic locking
Or you can add a package number in each data, and parse the number at server side.
就是我的需求应该是这样的。普通消息可以不同玩家的请求异步处理,玩家自己的请求需要有顺序的处理。在特殊消息下,又需要所有玩家的请求也能有顺序的。比如抢单之类的
From client, never send another request before you get response of the pervious request.
request => response request => response request => response
And this option may help as well:
假设玩家先后向服务器发送了两条协议都会改变用户数据。异步情况下如何保证用户请求顺序问题?