#1 2017-12-15 10:21:29

tdanop
Member
Registered: 2015-01-16
Posts: 27

Client-Server Callbacks

Hi,

I would like to ask if client/server callbacks are possible to implement with mOrmort framework which rather support stateless behavior.

Offline

#2 2017-12-15 11:17:58

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

Re: Client-Server Callbacks

What do you mean?
I'm sorry I can't understand well your question, especially what you call a "stateless behavior" in this context.

Offline

#3 2017-12-15 11:53:02

tdanop
Member
Registered: 2015-01-16
Posts: 27

Re: Client-Server Callbacks

By stateless behavior I mean you can not broadcast messages from server to all connected clients through a predefined channel.

Offline

#4 2017-12-15 17:46:52

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

Re: Client-Server Callbacks

You can easily make a manual broadcasting by calling a list of callback interface instances from the server side.

The benefits are that
- it will work very fast (the loop and call to all interfaces array will be non blocking)
- you can tune which clients should be broadcasted (broadcasting to all clients is not a good idea in practice)
- if the code isn't over a network (e.g. the callback has been registered on the server side), the interface call will be directly in the same process, just like a regular method call, without using any websockets

At lower level, you can use TWebSocketServer.WebSocketBroadcast() to broadcast to all connected clients.

Offline

#5 2017-12-17 01:14:41

rclaros
Member
Registered: 2016-06-21
Posts: 8

Re: Client-Server Callbacks

Hi,

@ab Thanks for all your work.
It's amazing.

I have FPC and I have tried TWebSocketServer.WebSocketBroadcast(), with several "html" clients and it works very well. Excellent!

I would like not only to have websockets clients "html", but also to add clients made with mORMot.

I tried to do it with "THttpClientWebSockets" but I do not know how to use it.

I appreciate some guidance.

Offline

#6 2017-12-17 08:42:02

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

Re: Client-Server Callbacks

As I wrote, there is no way yet to broadcast  all clients of inteface-based services callbacks.
What is wrong with calling an interface callback in a loop on the server side? It will work even without WebSockets involved...

Anyway, how do you expect it to work with mORMOt clients?
By supplying a custom interface, e.g. ICallbackBroadcast, for the TSQLRestServer.Service?

Offline

#7 2017-12-17 13:17:34

rclaros
Member
Registered: 2016-06-21
Posts: 8

Re: Client-Server Callbacks

Okay. Thanks for the clarification.
I am a newbie, and I wanted my server (TWebSocketServer), to have communication via websockets, at the same time for clients "html" and mORMOt clients.

Offline

Board footer

Powered by FluxBB