TTMSMCPClientTransportSSE Class
Client transport that receives protocol messages from a server over a long-lived server-sent event stream and sends its own messages back as separate posted requests.
API unit family: TMS.MCP.Client.Transport.SSE
Inherits from: TTMSMCPClientTransport
Syntax
TTMSMCPClientTransportSSE = class(TTMSMCPClientTransport)
Remarks
This is the two-endpoint pattern of the older network transport: Start opens a streaming GET request to URL and keeps it open, and the server answers on that stream. Its first event names the address the client must post its own messages to; until that announcement arrives there is nowhere to send to and Send discards what it is given. OnInitialized reports the moment the address becomes known. A posted message is answered on the event stream rather than in the reply to the post, so the body of that reply is not read. Stream comments are skipped, and each data line is reported through OnMessage as one message. The stream is read on a background worker, so OnMessage, OnInitialized and the response notifications are all raised on that worker and not on the thread that started the transport; a handler that touches the user interface must marshal the work. Applications normally do not create this class directly, because the client component selects and configures a transport from the transport type recorded on the server entry; create one explicitly only when driving the protocol by hand.
Properties
| Name | Description |
|---|---|
| URL | Address of the event stream the transport connects to. |
Methods
| Name | Description |
|---|---|
| IsRunning | Reports whether the transport has been started and not yet stopped. |
| Send | Posts one JSON-RPC message, given only its payload, to the address the server announced on the stream. This is the overload to call in the ordinary case, where the serialized message is all the caller has. |
| Start | Opens the event stream to URL and begins reading it. |
| Stop | Signals the reader worker to end and marks the transport as no longer running. |
Events
| Name | Description |
|---|---|
| OnCreateIOHandler | Occurs before a secure stream connection is opened, so that the application can supply the connection handler itself instead of letting the transport create a default one. |
| OnHTTPCustomHeaders | Occurs before the stream request is issued, so that the application can add its own request headers, for instance to carry credentials. |
| OnHTTPResponse | Occurs when the stream request came back with a status other than success, which means no stream was established. |
| OnInitialized | Occurs once the server has named the address the client must post its messages to, which is the point where the transport becomes able to send. |
| OnResponse | Occurs with the status and headers of the stream response, before its body is consumed. |