简体   繁体   中英

Is it possible to identify web-socket request on receive?

I have two queries that are sent one after the other. If I use send method, than I get the response in onmessage and I need to know which response it was - from the first query or from the second. Is it possible?

You should add a correlation id to each request, and return that id with the response, that way the client would know which response is associated with which request.

Since it is a client concern, the id can be a simple incremental integer, does not need to be a GUID or unique number. The server just have to attach the request id to the response, does not need to do anything with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM