I am looking for someone who has experience with the library Chilkat Websocket.
We want to build a Websocket Client. But the information on the website of Chilkat doesnt help me...
I have some experience with websockets in C#, and thats really easy to set up.
But in the chilkat library for dataflex there are alot of steps to start a websocket. Steps that are not very clear to me.
For example:
Code:
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
Get ComConnect Of hoRest "someserver.com" 80 False False To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
I have only the url to the websocket, which starts with 'wss'. In the documentation on the chilkat website, i cannt figure out what i have to use of the url to use in the method 'ComConnect'.
After that you have to create a handshake:
Code:
// Add the standard WebSocket open handshake headers that will be needed.
// (This adds the required HTTP request headers to the rest object.)
Get ComAddClientHeaders Of hoWs To iSuccess
// Add any additional headers that might be desired.
// Two common WebSocketSpecific headers are "Sec-WebSocket-Protocol" and "Origin".
Get ComAddHeader Of hoRest "Sec-WebSocket-Protocol" "x-something" To iSuccess
Get ComAddHeader Of hoRest "Origin" "http://someserver.com" To iSuccess
// Do the open handshake.
Get ComFullRequestNoBody Of hoRest "GET" "/something" To sResponseBody
Get ComLastMethodSuccess Of hoRest To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
For starters, How do you do a handshake WITH a body?
After you have finally created a handshake, we have to listen to messages that come in. This will be json objects. And i cannt find the method that recieves messages, only some methods that recieve 'frames'.
Can someone help me? I am really struggling because the documentation of this library is sooo poor. Or has someone another library for websockets, thats easier to learn.