Table of Contents

TTMSMCPTransport Class

Base class for the server-side message channels: it owns the running state and the handlers that connect a channel to the server, and defines the contract a concrete channel implements.

API unit family: TMS.MCP.Transport Inherits from: TTMSMCPCustomComponent

Syntax

TTMSMCPTransport = class(TTMSMCPCustomComponent)

Remarks

This class is abstract. A descendant must override TTMSMCPTransport.Start, TTMSMCPTransport.Stop, TTMSMCPTransport.ProcessMessages and TTMSMCPTransport.Run, and is expected to set the protected running flag from Start and Stop so that TTMSMCPTransport.Running reports the real state. Inbound messages are routed through the protected DispatchMessage helper, which picks TTMSMCPTransport.OnProcessMessageContext when it is assigned and falls back to TTMSMCPTransport.OnProcessMessage, and returns the text to write back to the client. A descendant that opens and closes sessions reports them through the protected NotifySessionCreated and NotifySessionRemoved helpers. The session-aware members - TTMSMCPTransport.ActiveSessionIds, TTMSMCPTransport.SessionCount, TTMSMCPTransport.SendNotificationToSession, TTMSMCPTransport.BroadcastNotification and TTMSMCPTransport.SendRequestToSession - behave here as if there were no sessions at all. A descendant that can tell its clients apart overrides them; one that cannot inherits the no-op behavior unchanged.

Properties

Name Description
Running Reports whether the channel is currently open: True while it is running and able to exchange messages, False before it is started and after it stops. Read-only.

Methods

Name Description
ActiveSessionIds Returns the identifiers of the sessions that are currently open.
BroadcastNotification Pushes a server-initiated notification to every open session.
ProcessMessages Processes whatever inbound traffic is currently pending, then returns.
Run Starts the channel if needed and keeps serving until it stops.
SendNotificationToSession Pushes a server-initiated notification to one session.
SendRequestToSession Tries to push a server-initiated request to one session over whatever live channel is open for it.
SessionCount Returns how many sessions are currently open.
Start Opens the channel so clients can connect and messages can be exchanged.
Stop Closes the channel and releases the resources it opened.

Events

Name Description
OnError Handler called for every exception the channel catches internally.
OnGetSessionProtocolVersion Handler the channel calls to look up the protocol version negotiated for a session.
OnProcessMessage Handler called for every inbound message, without session context.
OnProcessMessageContext Handler called for every inbound message, with the session it arrived on.
OnSessionCreated Fires when a session-aware channel opens a new session.
OnSessionRemoved Fires when a session-aware channel ends a session.

Used by