TTMSFNCWhatsAppReceiver
The TTMSFNCWhatsAppReceiver
is a non-visual component to receive messages sent to a WhatsApp account. For this component to receive WhatsApp messages it must connect to a server hosted by TTMSFNCWhatsAppServer
, running on a secure context. It uses TTMSFNCWebSocketClient
internally.
Receive messages
Whenever a message arrives from TTMSFNCWhatsAppServer
the OnBinaryDataReceived
/OnMessageReceived
event is triggered first, depending on the message format. After that in case of a string message it is further parsed internally into a record that contains all the WhatsApp message related information. Any incoming messages that don't follow the messages
field format will be discarded.
If a valid formatted message arrives the OnWhatsAppMessageReceived
event will be triggered. The AMessage
parameter contains the message details, such as sender name, phone number, message type, and so on...
Secure connection
The TTMSFNCWhatsAppServer
is always required to run in a secure context. This means the UseSSL
is set to True
and cannot be modified. See the Secure connection
part of TTMSFNCWebSocketClient
.
Properties
Property name | Description |
---|---|
Active: Boolean | Set True to connect and False to disconnect. |
HostName: string | Name of the host. |
PathName: string | Name of the path. For example: https://hostname:port/path |
Port: Integer | Port number. |
Methods
Method name | Description |
---|---|
Connect | Connect to a server and perform handshake. |
Disconnect(SendClose: Boolean = True) | Disconnect from the server. - Non-WEB The SendClose parameter is for non-WEB platforms only. If SendClose is False , the client will not send a closing frame. If True , it will send a closing frame and wait for reply from the server. |
Send(ABytes: TBytes) | Send a string message to the server. |
Send(AMessage: string) | Send a binary message to the server. |
Ping(AMessage: string)Non-WEB only | Sends a ping frame to the server with an optional message. |
Events
Event name | Description |
---|---|
OnBinaryDataReceived | Event triggered when binary data is received from the server. |
OnConnect | Event triggered when connection to the server is successful. |
OnDisconnect | Event triggered when client is disconnected from the server. - WEBTriggered automatically whenever the connection is lost. - Non-WEBDoes not trigger if the connection is suddenly lost. To make sure you have connection to the server, use the Ping method to periodically check the connection. |
OnMessageReceived | Event triggered when a string message arrives from the server. This includes both forwarded messages from the callback URL and the BroadcastMessage /SendMessageTo calls by the server. |
OnPingNon-WEB only | Event triggered when a ping message is received from the server. |
OnPongNon-WEB only | Event triggered when a pong message is received from the server. |
OnWhatsAppMessageReceived | Event triggered when a valid message field formatted message arrives from the server. |