Question

I make different instances of TIdTcpServer and assign a pointer to the Data property that I need later on if a Client Connects/Disconnects/Executes.

Is it possible to get the "Parent" TIdTcpServer from a TIdContext?

If so, how can I do that?

Example:

procedure TMainWindow.OnConnect(AContext: TIdContext);
var
 ParentServer : TIdTcpServer; 
begin
  // ParentServer := AContext... 
end;
Was it helpful?

Solution

Type-cast the TIdContext to a TIdServerContext, then you can access its public Server property:

procedure TMainWindow.OnConnect(AContext: TIdContext);
var
  ParentServer : TIdCustomTCPServer; 
begin
  ParentServer := TIdServerContext(AContext).Server;
  ...
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top