For VCL and FMX applications, the OpenSSL libraries next to the executable; the receiver always connects securely.
Add the component
Drop TTMSFNCWhatsAppReceiver from the TMS FNC WebSocket palette page onto a form, or create one at runtime.
Set HostName and Port (and PathName when the server uses one) to the address of the WhatsApp server.
Handle OnWhatsAppMessageReceived, then set Active := True or call Connect.
Handle incoming messages
Connect and handle incoming messagesPascalC++
procedure TForm1.FormCreate(Sender: TObject);
begin
// wss://hooks.example.com:443/ - the host running TTMSFNCWhatsAppServer
TMSFNCWhatsAppReceiver1.HostName := 'hooks.example.com';
TMSFNCWhatsAppReceiver1.Port := 443;
TMSFNCWhatsAppReceiver1.Active := True;
end;
procedure TForm1.TMSFNCWhatsAppReceiver1WhatsAppMessageReceived(Sender: TObject;
AMessage: TTMSFNCWhatsAppReceiverMessage);
var
Line: string;
begin
// Read what you need now: AMessage is freed when the handler returns.
Line := AMessage.From.Name + ' (' + AMessage.From.Phone + '): ' + AMessage.Text.Body;
// In VCL and FMX applications this event runs on a background thread.
TThread.Queue(nil,
procedure
begin
Memo1.Lines.Add(Line);
end);
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// wss://hooks.example.com:443/ - the host running TTMSFNCWhatsAppServer
TMSFNCWhatsAppReceiver1->HostName = "hooks.example.com";
TMSFNCWhatsAppReceiver1->Port = 443;
TMSFNCWhatsAppReceiver1->Active = true;
}
void __fastcall TForm1::AddLine()
{
Memo1->Lines->Add(FLine);
}
void __fastcall TForm1::TMSFNCWhatsAppReceiver1WhatsAppMessageReceived(TObject *Sender,
TTMSFNCWhatsAppReceiverMessage *AMessage)
{
// Read what you need now: AMessage is freed when the handler returns.
FLine = AMessage->From->Name + " (" + AMessage->From->Phone + "): " + AMessage->Text->Body;
// In VCL and FMX applications this event runs on a background thread.
TThread::Queue(nullptr, AddLine);
}
Next steps
Receiving messages — message types, contacts, media, and thread-safe handling.
API reference — full class, property, method, and event reference.