Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTP/TCPServer Intercept
#1
I'm setting up intercepts like this in my OnConnect events to track total bytes coming in and going out:

Code:
AContext.Connection.Intercept := TIdConnectionIntercept.Create(AContext.Connection);  // track total bytes in and out
AContext.Connection.Intercept.OnReceive := InterceptEvents.OnReceive;
AContext.Connection.Intercept.OnSend := InterceptEvents.OnSend;

Do I need to call AContext.Connection.Intercept.Free in the OnDisconnect event or does that get cleaned up automatically when the connection ends?
Reply
#2
(05-05-2022, 05:33 PM)kbriggs Wrote: Do I need to call AContext.Connection.Intercept.Free in the OnDisconnect event

No. The server will free the Intercept after firing the OnDisconnect event (unless the event handler raises an exception). But, even if the server didn't free the Intercept automatically, you are assigning the AContext.Connection as the Owner of the Intercept, so the Intercept would be freed anyway when the Connection is freed.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)