#1 2022-12-02 11:36:55

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

LongWorkClient Demo for Web

Can someone help me how to implement \Samples\31 - WebSockets to work on web together with delphi client? 

I tried postman:
ws://localhost:8888/root/LongWorkCallback.WorkFinished

Request URL: http://localhost:8888/root/LongWorkCallback.WorkFinished
Request Method: GET
Status Code: 400 WebSocket Upgrade Error

I have no idea how to start the websocket listener that will handle particular events.

Offline

#2 2022-12-02 17:00:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: LongWorkClient Demo for Web

The protocol used is an encapsulation of REST over the WebSockets frames, in both directions.
So the URL is not a "postman" URI.

So, you can't use interface callbacks with a Web client.
Define your own protocol, then use a frame to notify the client from the server. But you won't be able to do it directly from an interface.

It may be feasible to make a Web client compatible with the mORMot REST encapsulation, but it is somewhat complex.
There is a full query/answer pattern added to the WS frames limited layout.
The reference code is TWebSocketProtocolJson.FrameDecompress/FrameDecompress as used by the TWebSocketProtocolRest class.

Online

Board footer

Powered by FluxBB