#1 2025-12-13 15:58:40

rcla
Member
Registered: 2025-12-13
Posts: 3

Example Echo with TWebSocketAsyncServer

I have done Example of an asynchronous HTTP WebSocket Echo Server with TWebSocketAsyncServer.

Point your browser to http://localhost:8888/ for initial page using the existing file "restws_simpleechserver.html"

Full Code

What I've noticed is that when connecting for the first time, "Sender.Protocol.ConnectionID" starts at 2 or 3, not 1.

I hope this example is helpful and can be included in the official mORMot2 GitHub repository.

Thank you very much for such excellent work.

Offline

#2 2025-12-13 16:10:43

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,328
Website

Re: Example Echo with TWebSocketAsyncServer

Thanks for the feedback and interest.

I guess it is just
https://github.com/synopse/mORMot2/blob … server.dpr
but using THttpWebsocketAsyncServer class, isn't it?

Offline

#3 2025-12-13 16:35:11

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

Re: Example Echo with TWebSocketAsyncServer

IMO, that kind of simple examples is prefect for anyone approaching mORMot2; what for an expert is "just ..." for a newcomer is "ah, that's what I was looking for"

Offline

#4 2025-12-13 16:51:42

rcla
Member
Registered: 2025-12-13
Posts: 3

Re: Example Echo with TWebSocketAsyncServer

ab wrote:

Thanks for the feedback and interest.

I guess it is just
https://github.com/synopse/mORMot2/blob … server.dpr
but using THttpWebsocketAsyncServer class, isn't it?

Almost, it also has DoOnRequest which loads the file "restws_simpleechoserver.html"

Offline

#5 2025-12-13 16:56:33

rcla
Member
Registered: 2025-12-13
Posts: 3

Re: Example Echo with TWebSocketAsyncServer

Javierus wrote:

IMO, that kind of simple examples is prefect for anyone approaching mORMot2; what for an expert is "just ..." for a newcomer is "ah, that's what I was looking for"

IMHO, I agree with you.

Thanks.

Offline

#6 Today 05:43:21

zen010101
Member
Registered: 2024-06-15
Posts: 139

Re: Example Echo with TWebSocketAsyncServer

Javierus wrote:

IMO, that kind of simple examples is prefect for anyone approaching mORMot2; what for an expert is "just ..." for a newcomer is "ah, that's what I was looking for"

Maybe we can generate many simpler examples using Claude Code and merge them into the master branch smile

Offline

Board footer

Powered by FluxBB