Hi
I have five interfaces for a server and I intercept its onCreate event to do something every now and then. I know that, when I am in that event, the thread is already created and every object I create here will be exclusive for that thread.
Now I have a method that needs to be called for every interface on datamodule’s creation and destruction. Is there any event at server that could be used for that?
I know that I could implement that at every onCreate datamodule event but is there a better way to to that?
I use TROHttpServer created and configured manually.
If I understood you correctly, I think that if you create a base service and inherit your 5 services from that base you could do the OnCreate only on the base. I have something similar in my server, where I get the database connection and stuff like that that I have to do for every service, and it works fine.
If I follow this solution, how can I access some field in the service dataModule? Not from the inherited dataModules but from code elsewhere in the server? I know that this is not related to the proposed solution, but as the server itself creates the data modules “on the fly” (as each request arrives), if a have a field in the base (or even in the inherited) datamodule, how can I access this field from outside the datamodule?
To access the dm instance from code elsewhere in the server you don’t have much options except pass a reference of it via parameter to the function/procedure that would need to access such datamodule, or similar ideas. You “can’t” have global variables on a MT app, and this RO server apps are very much multithreaded apps.