Indy 9
|
TIdConnectionIntercept = class(TIdBaseComponent)
TIdConnectionIntercept descendants can be used by TIdTCPConnection and descendants to act as an intermediary between the socket binding for the connection and low-level operations that communicate with the protocol stack.
TIdConnectionIntercept provides virtual methods to respond to Connect and Disconnect requests for a socket binding by capturing or releasing a reference to the TIdSocketHandle used by the protocol stack.
The socket handle will be used to access data before messages are sent and/or after responses are received. Developers can use TIdConnectionIntercept descendants to encrypt and decrypt data, or to compress and decompress messages.
Additional virtual methods can be used to perform the Send or Recv operation in behalf of the original socket connection. TIdConnectionIntercept can also allow the socket connection to complete the input/output operation by changing the SendHandling and ReceiveHandling properties.
Note: Do not create instances of TIdConnectionIntercept. Use descendant classes, like TIdConnectionInterceptOpenSSL or TIdLogDebug, or create custom descendants that implement the virtual methods of TIdConnectionIntercept.
property Connection: TComponent;
property IsClient: Boolean;
procedure Connect(AConnection: TComponent); virtual;
Connect generates a TNotifyEvent event when the OnConnect event handler has been assigned to respond to the connection event.
Connect is a virtual method in TIdConnectionIntercept, and can be re-implemented in descendant classes to provide additional connection handling appropriate to the socket handler.
constructor Create(AOwner: TComponent); override;
procedure Disconnect; virtual;
Disconnect is a virtual method that sets the value of Binding, assigned in the Connect method, to Nil. Clearing the reference in Binding will prevent further socket notifications to the socket handler.
TIdConnectionIntercept descendants should implement Disconnect to perform the operations appropriate to the socket handler.
procedure Receive(ABuffer: TStream); virtual;
Receive is used in conjunction with DataReceived to allow the TIdConnectionIntercept to perform transformations for any data read from the protocol stack.
Note: Receive is a virtual method in TIdConnectionIntercept and always returns 0 as the result value. Descendant classes should implement Receive to perform socket read operations appropriate for the socket handler.
procedure Send(ABuffer: TStream); virtual;
Return Values:
Integer - Number of bytes sent. Default Value is 0.
Send is used in conjunction with DataSent to allow the TIdConnectionIntercept to perform transformations for any data written to the protocol stack.
Note: Send is a virtual method in TIdConnectionIntercept and always returns 0 as the result value. Descendant classes should implement Send to perform socket write operations appropriate for the socket handler.
property OnConnect: TIdInterceptNotifyEvent;
ABinding is the TIdSocketHandle socket handle for the peer connection, and is stored in Binding for use during read and write operations.
Assign a procedure to OnConnect to perform special processing when a connection notification is received in the Connect method. Applications must assign an OnConnect event handler in order to respond to connection notifications.
property OnDisconnect: TIdInterceptNotifyEvent;
Applications must assign a procedure to the TIdInterceptNotifyEvent event handler to allow responding to the event notification.
property OnReceive: TIdInterceptStreamEvent;
Applications must assign a procedure to the TIdInterceptStreamEvent event handler to allow responding to the event notification.
property OnSend: TIdInterceptStreamEvent;
Applications must assign a procedure to the TIdInterceptStreamEvent event handler to allow responding to the event notification.