#1 2024-10-16 11:08:23

Javierus
Member
Registered: 2019-09-18
Posts: 55

Websockets

Sincerely, I lose myself inside mORMot
I do know many people in Delphi looks for websockets libraries, and find only a commercial one (esegece), and an open repo on GitHub, that seems not fully complete
Then I think mORMot has websockets implemented, but I don't really know if it can be used "detached" from the REST/HTTP/ORM stuff

At embarcadero website there is a post one an example using esegece websockets, just a simple chat:
https://blogs.embarcadero.com/example-w … plication/

I know there are examples in mORMot2 using interfaces, but I believe that would not be inbteroperable with other languages/platforms that also have websockets implemented (i.e. javascript)

Is it possible doing it as easily in mORMot? Obviously without non-visible components, but code-created Delphi classes

Offline

#2 2024-10-16 15:56:44

flydev
Member
From: France
Registered: 2020-11-27
Posts: 73
Website

Re: Websockets

Hi, I’ve just published a project that you might want to check out. Its based of a larger project I’m working on (inspired by Rails ActionCable and designed to work with mormot MVC). I’ve stripped the code a bit, so you’ll get a WebSockets server and some event handling. I’ve also included a JS client for chat functionality.

I’ll try to create a lighter sample this weekend based on the example you linked from Embarcadero.

You will need NPM or yarn installed to run the js project. I can build it to be ran without js tooling, just let me know. Anyway, you can connect with any websockets client on `ws:127.0.0.1:8082/cable` endpoint.

Files of interest:
- chat_channel.pas
- token/token.pas
- http-server/ws_server.pas

Do not pay attention to InitMVCApp and other mvc things.. hope it help smile

url:   https://github.com/flydev-fr/mormot-cable

Offline

#3 2024-10-16 18:31:27

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

Re: Websockets

You can take a look at
https://github.com/synopse/mORMot/blob/ … Server.dpr

This sample from mORMot 1 still applies, and it works with a JavaScript client and a mORMOt server.

Offline

Board footer

Powered by FluxBB