TTMSMCPClientTransportHTTP Class
Client transport that talks to a server over a single streamable network endpoint, posting each protocol message as its own request and reading the answer from that request's reply.
API unit family: TMS.MCP.Client.Transport.HTTP
Inherits from: TTMSMCPClientTransport
Syntax
TTMSMCPClientTransportHTTP = class(TTMSMCPClientTransport)
Remarks
This is the current network transport, and it uses one address for both directions: Send posts a message to URL and the server answers in the reply to that same request. The answer may be a plain payload carrying one message or a batch of them, or an open event stream over which the server sends several messages before the request completes; either way each message is reported through OnMessage. A server that has accepted a message without producing an answer sends no payload at all. Start opens no connection: it only marks the transport as running and raises OnInitialized, and the first request is issued when the first message is sent. Each message is posted by its own background worker, so Send returns at once and OnMessage together with the response notifications are raised on those workers rather than on the thread that sent the message; a handler that touches the user interface must marshal the work. Several messages may therefore be in flight at the same time, and their answers are not necessarily reported in the order the messages were sent. The session the server opens is tracked automatically: the identifier the server returns on its first answer is remembered and sent with every later request, and Stop ends that session on the server. A server that reports the session as gone makes the transport drop it and start a fresh one. When the server refuses a request as unauthorized, an authorization flow is run through OAuth and the refused message is sent again once it succeeds. 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 |
|---|---|
| OAuth | Authorization helper that answers a server's refusal of an unauthorized request and holds the resulting access token. |
| ProtocolVersion | Protocol revision the connection has settled on, announced on every request. |
| URL | Address of the endpoint every message is posted to. |
Methods
| Name | Description |
|---|---|
| IsRunning | Reports whether the transport accepts messages. |
| Send | Posts one JSON-RPC message to URL. |
| Start | Marks the transport as running so that messages may be sent, and reports that it is ready. |
| Stop | Ends the session on the server and stops every worker the transport is running. |
Events
| Name | Description |
|---|---|
| OnConnectionNotSupported | Occurs when the server rejects the request method this transport uses, which means the endpoint does not speak this transport at all. |
| OnCreateIOHandler | Occurs before a secure 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 each request is issued, so that the application can add its own request headers, for instance to carry credentials. |
| OnHTTPResponse | Occurs when a request failed, reporting the status the server answered with and the body that came with it. |
| OnInitialized | Occurs when the transport has been marked as running and is ready to accept messages. |
| OnResponse | Occurs with the status and headers of a response as soon as they arrive, before its body is read. |