TTMSFNCWebsocketClient Class
WebSocket client component for use at design time. Publishes the connection settings and events of TTMSFNCCustomWebsocketClient so they can be configured in the IDE.
API unit family: TMSFNCWebSocketClient
Inherits from: TTMSFNCCustomWebsocketClient
Syntax
TTMSFNCWebsocketClient = class(TTMSFNCCustomWebsocketClient)
Properties
| Name | Description |
|---|---|
| Active | When set to True, connects and performs the handshake; when set to False, disconnects. Reading reflects the current connection state. Defaults to False. (inherited from TTMSFNCCustomWebsocketClient) |
| AutoCheckInterval | Interval in milliseconds used by the background driver when automatic message checking is enabled. Defaults to 50. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| AutoCheckMessages | When True, incoming messages are checked automatically by the background driver. When False, call CheckIncoming manually. Defaults to True. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| AutoSyncEvents | When True, received-message events are queued to the main thread so handlers can safely update the UI. When False, events fire on the background driver thread. Defaults to True. (inherited from TTMSFNCCustomWebsocketClient) |
| BoundIP | Local IP address to bind the outgoing socket to. Leave empty to let the system choose. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| CheckTimeout | Time in milliseconds CheckIncoming waits for data. A value of 0 returns immediately. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| ConnectTimeout | Time in milliseconds to wait for the connection to be established. A value of 0 uses the platform default. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| FrameSize | Maximum payload size, in bytes, per frame used when SplitMessage is True. A value of 0 means no splitting. Defaults to 0. (inherited from TTMSFNCCustomWebsocketClient) |
| HostName | Host name or address of the server to connect to. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| Options | Connection options applied to the session. Defaults to an empty set. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| Origin | Optional Origin header value sent with the handshake. Mainly relevant for browser clients. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| PathName | Resource path requested in the handshake GET line, for example /chat. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| Port | TCP port of the server to connect to. Defaults to the standard WebSocket port. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
| SplitMessage | When True, outgoing messages larger than FrameSize are split across multiple frames. Defaults to False. (inherited from TTMSFNCCustomWebsocketClient) |
| UseSSL | When True, uses a secure (TLS) connection. Defaults to False. Cannot be changed while connected. (inherited from TTMSFNCCustomWebsocketClient) |
Methods
| Name | Description |
|---|---|
| CheckIncoming | Checks the connection for incoming data and processes one frame when available, waiting up to the configured check timeout. A received close frame triggers a disconnect. (inherited from TTMSFNCCustomWebsocketClient) |
| Connect | Opens the connection to the configured host and port and performs the upgrade handshake. On success the connection is registered for message checking and the connect event fires; on handshake failure the connection is closed. Does nothing when already connected. (inherited from TTMSFNCCustomWebsocketClient) |
| Disconnect | Closes the connection. When is True, a close frame is sent first; otherwise the socket is closed immediately. Does nothing when not connected. (inherited from TTMSFNCCustomWebsocketClient) |
| IsConnected | Indicates whether the underlying socket is currently connected. (inherited from TTMSFNCCustomWebsocketClient) |
| Ping | Sends a ping control frame carrying the given text as its payload. (inherited from TTMSFNCCustomWebsocketClient) |
| Pong | Sends a pong control frame carrying the given text as its payload. (inherited from TTMSFNCCustomWebsocketClient) |
| Send | Sends raw binary data as one or more frames, splitting it when message splitting is enabled. (inherited from TTMSFNCCustomWebsocketClient) |
| SendMasked | Sends raw binary data with the payload masked, as required for client-to-server frames. (inherited from TTMSFNCCustomWebsocketClient) |
Events
| Name | Description |
|---|---|
| OnBinaryDataReceived | Fires when a binary message is received. (inherited from TTMSFNCCustomWebsocketClient) |
| OnConnect | Fires when the connection is established and the handshake completes. (inherited from TTMSFNCCustomWebsocketClient) |
| OnCreateIOHandler | Fires before a secure connection is established, allowing a custom I/O handler to be supplied. (inherited from TTMSFNCCustomWebsocketClient) |
| OnDisconnect | Fires when the connection is disconnected. (inherited from TTMSFNCCustomWebsocketClient) |
| OnHandshakeResponse | Fires when the server handshake response is received and validated, allowing the connection to be accepted or rejected. (inherited from TTMSFNCCustomWebsocketClient) |
| OnMessageReceived | Fires when a text message is received. (inherited from TTMSFNCCustomWebsocketClient) |
| OnPing | Fires when a ping control frame is received. (inherited from TTMSFNCCustomWebsocketClient) |
| OnPong | Fires when a pong control frame is received. (inherited from TTMSFNCCustomWebsocketClient) |
| OnSendHandshake | Fires just before the handshake request is sent, allowing the headers to be inspected or modified. (inherited from TTMSFNCCustomWebsocketClient) |