Blog
All Blog Posts | Next Post | Previous PostIntroducing TMS FNC WebSocket
Thursday, October 27, 2022
Today a new member joins the TMS FNC family: TMS FNC WebSocket!
In TMS FNC WebSocket you'll find easy to use server and client components for WebSocket communication. Both the server and the client implement the RTF 6455 standard for WebSocket Protocol, so the components can be mixed and used with existing WebSocket clients and servers.
Simply drop them on a form, set the few required properties such as port number and host name and they are ready to connect. Of course, starting up a server that does nothing or connecting to a server without doing anything with the incoming messages is rarely enough so let's take a look at the capabilities!
TTMSFNCWebSocketServer
Receiving and sending messages as one would expect is possible. There are separate events and methods available for text and binary data based messages. You can also broadcast a message to all connected clients or decide yourself which clients should receive the message.
But is it secure? Yes, the TTMSFNCWebSocketServer also supports the WebSocket Protocol over TLS!
TTMSFNCWebSocketClient
Not only the server needs to be able to send and receive messages but also the client. Just like in TTMSFNCWebSocketServer, separate events and methods are available for dealing with text and binary messages. Sending a text message to the server is as simple as:
TTMSFNCWebSocketClient.Send('Hello world');
We also made sure to make TTMSFNCWebSocketClient as compatible with the existing TWebSocketClient component (TMS WEB Core) as possible so you can reuse your existing code without headaches!
WhatsApp webhooks
Along with our new TMS FNC Cloud Pack v2.5 release we added support for sending WhatsApp messages. What about receiving messages?
The WhatsApp Business API requires a webhook to receive messages. Utilizing the power of TTMSFNCWebSocketServer, the TTMSFNCWhatsAppServer allows you to run a server that serves as the callback URL for the WhatsApp Business API. This makes it possible to catch the incoming messages that you are subscribed to.
You can either parse the incoming JSON messages yourself or take advantage of the TTMSFNCWhatsAppServer forwarding these messages for you to the connected TTMSFNCWhatsAppReceiver clients! The TTMSFNCWhatsAppReceiver will do the parsing for you resulting in an object that contains all the message details, such as sender name, phone number, message id, and so on...
WebSockets in action
Can't wait to see WebSockets working in native and WEB environments? Watch this video we prepared for the launch!
Availability?
TMS FNC Websocket is available as a standalone product and as expected, it is also part of TMS ALL-ACCESS and TMS FNC Component Studio.
Tunde Keller
This blog post has received 9 comments.
It''s non-trivial. We''ll check demand for next versions.
Bruno Fierens
stlcours
Is this will replace MQTT at some point ?
Baudewyns Robert
I see is as just another choice for real-time communications between server and both native & web clients.
Bruno Fierens
Dave
Akerman David
At version 1.0 , it is looking great.
Looking forward to the updates.
Kamran
https://github.com/synopse/mORMot2/blob/master/src/net/mormot.net.ws.client.pas
https://github.com/synopse/mORMot2/blob/master/src/net/mormot.net.ws.server.pas
https://github.com/synopse/mORMot2/blob/master/src/net/mormot.net.ws.core.pas
Eduard Appelhans
Interesting suggestion that we have not investigated yet. We''ll need to research this first if and how we could do this integration with MQTT.
Bruno Fierens
All Blog Posts | Next Post | Previous Post
If not, do you plan to make it available for FPC too?
Dimitris Kounalakis