I have a TCPSocket in my project, and I want to use it from several different parts of my code by instantiating the object like
Dim s as new AppTCPSocket s.initializeSettings(settings) s.connect()
But the problem is, when the TCPSocket has events that fire, I’m having a bit of a confusing time trying to figure out how to get that status back to other parts of the code. In other languages, I might add a callback to the TCPSocket’s event handler, or register a listener, or have TCPsocket send an event to another object. Something is necessary so that, when something happens to the TCPSocket, my app can respond.
I’m not sure how to do this in Xojo. I can’t seem to find any documented way to get a reference to a function (and haven’t tried yet) or call a function by name through a string variable. But I also wonder what I am supposed to do with TCPSocket events - maybe I need to rethink my object structure.
I don’t want to reference a specific control in my AppTCPSocket class. I could subclass AppTCPSocket for each type of control I want it to interact with but yuck - I really don’t want my AppTCPSocket derivatives to know anything at all about my user interface.
Any help would be appreciated, or a pointer to an example project perhaps where a non-UI control connects with several different controls of the UI.
And regardless, does Xojo support any type of callback mechanism? Can I pass a function as a parameter? That seems genuinely useful in many circumstances and is possible in every other language I use, so seems good to know.