Event handler signalled when disconnecting the client connection.
property OnDisconnect: TIdServerThreadEvent;
OnDisconnect is an event handler for a TIdServerThreadEvent event, and occurs when the after execution and during disconnection of the client from the TCP server.
OnDisconnect receives a TIdContext instance that represents the executing client task being disconnected. OnDisconnect is triggered when the TIdContext instance in Contexts has finished executing, and just prior to closing the socket connection for the client.
Assign a TIdServerThreadEvent event handler procedure to OnDisconnect to allow responding to the event notification.
Do not call Synchronized methods in the OnDisconnect event handler. This is important because OnDisconnect is called when active client tasks are terminated when the server sets Active to False. Using synchronized methods in OnDisconnect can result in a deadlock condition, caused when the thread is suspended while the method is executing in the main VCL thread.
TIdCustomTCPServer will detect the deadlock condition, but a timeout error will be raised while trying to terminate the active tasks for client connections.
Use Thread.Notification to act on the notification that a component is being inserted or removed. For example, if a component has object fields or properties that contain references to other components, it can check the notifications of component removals and invalidate those references as needed.
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.