Getting started with TMS FNC WebSocket Server
Prerequisites
- TMS FNC Core and TMS FNC WebSocket installed and the runtime packages added to the project.
Add the component
- Drop
TTMSFNCWebSocketServerfrom the TMS FNC WebSocket palette page onto a form, or create one at runtime. - Set
Portto the port the server should listen on. - Wire
OnConnect,OnDisconnect, andOnMessageReceived, then setActive := Trueto start listening.
The minimal server — port, connection events, and starting it:
procedure TForm1.StartServer;
begin
FServer := TTMSFNCWebSocketServer.Create(Self);
FServer.Port := 5050;
FServer.OnConnect := ServerConnect;
FServer.OnDisconnect := ServerDisconnect;
FServer.OnMessageReceived := ServerMessageReceived;
FServer.Active := True; // begin listening for clients
end;
procedure TForm1.StopServer;
begin
FServer.Active := False;
end;
procedure TForm1.ServerConnect(Sender: TObject; AConnection: TTMSFNCWebSocketConnection);
begin
Log('A client connected');
end;
procedure TForm1.ServerDisconnect(Sender: TObject; AConnection: TTMSFNCWebSocketConnection);
begin
Log('A client disconnected');
end;
Next steps
- Guides — running a server (including TLS) and broadcasting between clients.
- API reference — full class, property, method, and event reference.