WinHttpSendRequest has a dwContext parameter so that I can read the context from WINHTTP_STATUS_CALLBACK function. This context makes it possible to tell which WinHttpSendRequest is for the current callback.
Unfortunately and weirdly, though, WinHttpWebSocketSend does NOT have such context parameter at all. As a result, it is not possible to distinguish between multiple WinHttpWebSocketSend calls within WINHTTP_STATUS_CALLBACK function.
Can anybody help me with this please?
For your reference, I am trying to modify the following example to work with a websocket.
https://msdn.microsoft.com/en-us/library/aa383138%28VS.85%29.aspx#additional
The websocket resource I am trying to get is: https://api.upbit.com/websocket/v1. Once connected, you can send the following resource string for testing:
[{"ticket":"test"},{"format":"SIMPLE"},{"type":"trade","codes":["KRW-BTC","BTC-BCH"]},{"format":"SIMPLE"}]
If things go well, you will receive:
{"mk":"KRW-BTC","tms":1523531768829,"td":"2018-04-12","ttm":"11:16:03","ttms":1523531763000,"tp":7691000.0,"tv":0.00996719,"ab":"BID","pcp":7429000.00000000,"c":"RISE","cp":262000.00000000,"sid":1523531768829000,"st":"SNAPSHOT"} {"mk":"BTC-BCH","tms":1523531745481,"td":"2018-04-12","ttm":"11:15:48","ttms":1523531748370,"tp":0.09601999,"tv":0.18711789,"ab":"BID","pcp":0.09618000,"c":"FALL","cp":0.00016001,"sid":15235317454810000,"st":"SNAPSHOT"} {"mk":"KRW-BTC","tms":1523531769250,"td":"2018-04-12","ttm":"11:16:04","ttms":1523531764000,"tp":7691000.0,"tv":0.07580113,"ab":"BID","pcp":7429000.00000000,"c":"RISE","cp":262000.00000000,"sid":1523531769250000,"st":"REALTIME"}
I have a source project file you can download: https://1drv.ms/u/s!AiVorOunaPYdhAuHrggDk2EYa2X7
Once you download, compile and run it. Then you will see a dialog with 'Download' button and it will show - http://www.microsoft.com - WebSocket check box disabled
Click the Download button will show asynchronous WinHttpSendRequest working with a general site like http://www.microsoft.com.
I wanted to modify this demo program for a websocket server (https://api.upbit.com/websocket/v1). For that purpose, I '#define'd WSS_API_UPBIT Next, uncomment AsynchDemo.cpp's line 19 to
define WSS_API_UPBIT
Then run the demo again. This time you will see a little different dialog with - https://api.upbit.com/websocket/v1 - WebSocket check box enabled
Now, check the Websocket box and press Download. It will crash becasue of no context within callbacks.
thx