HTTPSecureSocket adding best practice

I’m sure this is an easy one. I really want to know what the best practice is for instantiating an HTTPSecureSocket Class where I can add handling to the PageReceived Event. I think I get confused due to the way Xojo has evolved over the years. In my project I’m forced to use the Xojo R2018.R4 or earlier due to dependancies on versions of glibc I can’t update on the deployment server. I remember I used to drag a socket class from the library which sat in the tray below the main app window. You could then set certain properties from the inspector, and you had a “control” in the explorer where you could tie code to events. Well…there is no “socket control” in the Library anymore. And I know I can instantiate them in code…but then how do I attach code to “events” supported by that thing. – and wouldn’t there be “scope” problems pending on where I instantiate the class from? I seem to have been able to use a generic object and set the parent class to HTTPSecureSocket – and then I can edit the properties in the inspector. yay! And then I can add code to events in the navigator. Yay! and then it doesn’t build because of a type mismatch error. Boo. How should I be doing this? In 2019R4 I have the regression issue where changing the Super on the Socket class doesn’t want to update the class properties in inspector…unless I quit and reload the project…and inconvenience but not a huge issue.

looks like I need to create my own class with the Super of HTTPSecureSocket, then add a “Generic” control to my project and set the super = my custom class name (which is a subclass of HTTPSecureSocket with no differences) – Then the code compiles with no errors…but you can’t necessarily edit all the properties in the inspector. Curious.

To do it in code, you use AddHandler. First create a method with the same parameters as the event, with one additional parameter that represents the socket itself.

myPageRecievedHandler(sock as HTTPSecureSocket, URL as String, HTTPStatus as Integer, Headers as InternetHeaders, Content as String)

Then use AddHandler to tie the method to your newly instantiated socket.

dim mySocket as new HTTPSecureSocket
AddHandler mySocket.PageRecieved, AddressOf myPageRecievedHandler

You will have to deal with the issue of scope as appropriate.