#1 Re: mORMot 1 » React with WebSockets on Linux » 2020-03-25 18:20:33

ab wrote:

The problem is on the JS side: there is currently no easy support of our WebSocket JSON frame format.
You have to make the decoding/encoding at hand.

Thanks.

I have modified code a little changing binary protocol to json one:

Project31LongWorkServer.dpr
  HttpServer.WebSocketsEnable(Server,'', True, False);

Project31LongWorkClient.dpr
  Client.WebSocketsUpgrade(PROJECT31_TRANSMISSION_KEY, True, False);

Project31SimpleEchoServer.html
  socket = new WebSocket("ws://localhost:8888/root", "synopsebin");

After that JS code connected to WS Server successfully.

So my last question here is could share some references where I can find details of JSON protocol? I'd like to try implementing it on JS side.

Thanks again for the perfect framework and your support.

Best regards,
Andrii.

#2 Re: mORMot 1 » React with WebSockets on Linux » 2020-03-25 13:22:34

ab wrote:

Interface-base services are over HTTP/REST by now for JavaScript.
They are not supported yet with JavaScript.
You can create asynch interface-based services in Delphi/FPC and consume them from Delphi/FPC, but you will have to write all the low-level JSON code by hand in JS if you want to have a JS client.

Ab, thanks for the answer.
I have the architecture the same you mentioned: 1) Delphi 7 server, 2) Delphi 7 Client, 3) Web (HTML5, JS) client. I'd like to use a unified data communication protocol to link them. I'm looking for Websockets-oriented classes in mORMot Framework to implement iterface-based approach.
As far as I know a communication between Delphi Server and Delphi Client could be done as like in Project31LongWorkServer and Project31LongWorkClient:
-- Client: TSQLHttpClientWebsockets;
-- Server: TSQLHttpServer.

But in the Project31SimpleEchoServer it is used TWebSocketServer which is perfectly works with JS Client but is not compatible with TSQLHttpClientWebsockets.

Sorry for the long description but could you please suggest some classes that I can use to combine Delphi Server, Delphi Client and JS Client based on interface approach?

Thanks,
Andrii.

#3 Re: mORMot 1 » React with WebSockets on Linux » 2020-03-24 14:37:07

ab wrote:

See in the '31 - WebSockets' folder the Project31SimpleEchoServer.dpr sample.
It is a low-level WebSockets server, and there is a JavaScript client.

We use such a dedicated "protocol" class for WebSockets protocol with React/Angular clients.
It is easier/more direct to work with than interface-based services, for a JS client.

But is it possible to implement interfaced-based services for a JS client?
I'm asking because it's a very powerful idea to systemize all commands/events between distributed software parts. It's not cool to neglect such a good tool like interfaced-based services doing instead low level Websockets interactions (parsing, formatting etc).

Thanks.

#4 Re: mORMot 1 » Web sockets examples » 2016-09-17 08:27:40

mpv wrote:

@aroxing - Does sgcWebSockets create a separate thread for each webSocket connection?

From the help:

TsgcWebSocketHTTPServer implements Server WebSocket Component and can handle multiple threaded client connections as TsgcWebSocketServer, and allows to server HTML pages using a built-in HTTP Server, sharing the same port for websocket connections and HTTP requests.

TsgcWebSocketServer implements Server WebSocket Component and can handle multiple threaded client connections.

TsgcWebSocketClient.... Methods :
Start: uses a secondary thread to connect to server, this prevents your application freezes while try to connect.
Stop: uses a secondary thread to disconnect from server, this prevents your application freezes while try to disconnect.

#5 Re: mORMot 1 » Web sockets examples » 2016-09-16 20:18:44

edwinsn wrote:

@aroxing,

It'll be helpful to others if you report back your usage experiences later smile

I've been using the sgcWebSockets library for several months and have to admit that it works quite well. Classes interfaces are elegant and full-fledged.
My use case consists of Delphi server and Delphi and Javascript clients. I did not try native Javascript WebSockets but js library provided by sgcWebSockets solves all usual actions (connect, disconnect, message send/receive, errors handling). I definitely recommend this library when web-sockets are needed in mutual Delphi-Web environment. By the way there are several useful features like authentication, sending binary data, SSL support etc.

#6 Re: mORMot 1 » Web sockets examples » 2016-05-03 12:29:57

@edwinsn, thanks a lot for commenting my issue.
I'm currently on the way to use the library you mentioned. Hope their implementation will fit all my requirements.

Thanks.

#7 Re: mORMot 1 » Web sockets examples » 2016-05-03 09:11:10

I'd be very appreciate it if somebody showed me the working code of Web sockets from real project except authors' examples.

Thanks.

#8 mORMot 1 » Web sockets examples » 2016-04-25 10:28:34

aroxing
Replies: 10

Hello.
My task is to develop Delphi-based Web sockets server and also Delphi-based and Browser-based clients.
I've analized samples provided with the library but did not find the solution. What the examples have:

1) Project31SimpleEchoServer.dpr - works fine with browser example but does not have Delphi client example. I used the way described here http://synopse.info/forum/viewtopic.php?id=3120 but ran into the same error message.

2) Project31ChatServer.dpr and Project31ChatClient.dpr work together but browser-based example from 1) doesn't. I suppose because of authentication.
I can't decide how to adapt Project31SimpleEchoServer.html to these server and client.

I'd like to ask the community to help me with examples either with a "Project31SimpleEchoServer.dpr" Delphi-based client or a browser-based "Project31ChatServer.dpr and Project31ChatClient.dpr" client.

Thanks in advance.

Board footer

Powered by FluxBB