Getting started with TMS FNC WebSocket Client
Prerequisites
- TMS FNC Core and TMS FNC WebSocket installed and the runtime packages added to the project.
Add the component
- Drop
TTMSFNCWebsocketClientfrom the TMS FNC WebSocket palette page onto a form, or create one at runtime. - Set
HostNameto the server address andPortto the server port. - Wire
OnConnect,OnDisconnect, andOnMessageReceived, then callConnect.
The minimal client — host, port, connection events, and connecting:
procedure TForm1.SetupClient;
begin
FClient := TTMSFNCWebsocketClient.Create(Self);
FClient.HostName := 'localhost';
FClient.Port := 5050;
FClient.OnConnect := ClientConnect;
FClient.OnDisconnect := ClientDisconnect;
FClient.OnMessageReceived := ClientMessageReceived;
FClient.Connect; // opens the connection asynchronously
end;
procedure TForm1.ClientConnect(Sender: TObject; AConnection: TTMSFNCWebSocketConnection);
begin
// Connected - it is now safe to Send.
sendBtn.Enabled := True;
end;
procedure TForm1.ClientDisconnect(Sender: TObject; AConnection: TTMSFNCWebSocketConnection);
begin
sendBtn.Enabled := False;
end;
Next steps
- Guides — connecting (including TLS) and sending and receiving messages.
- API reference — full class, property, method, and event reference.