Jump to content

server side timed execution routine


Recommended Posts



I've just create a TuniThreadTimer in my servermodule in order to generate serverside procedure, interval lunched.


First question is about the place into put that timer, is the servermodule the right place? ( i suppose this is the place where run somthing detached from the users sessions).


If the first question's answare is "yes, it is right", how can i access object designed in the mainmodule ? 


I suppose to use the objects declared in the mainmodule, like connections and querys, to perform my goals. Also instanziate a mainform or other unit to re-use the object declared inside and their own procedure.


It is all possible, or part of , or there is a way to simulate a session to use all declared classes?

Evenif what is the right design pattern to perform actions in server-side detached from users session with timer event?




Link to comment
Share on other sites

  • 1 month later...

hi everyone,


to day i come back to this feature. I've just test thread timer with log message succesfully.

I create the object into servermodule and set Enabled to True in create event of servermodule, so i can log current time every some second. (like this)


My problem is the same of previus message: I need to use object declared into mainmodule and into formmain (connection, querys and 2 o more function). 

How can i access from mytimerTimer() procedure in servermodule, to that objects?


PS: following execution in debug i have seen a function from UniGuiSession or uniApplication like initApplication, that (i think) was run after http request and session generation, My hope is to be able to run the same code that was runned inside the inizialization of a session, or simulate a session instead.


thanks in advantege for your help.


Link to comment
Share on other sites

If your ThreadTimer is going to access DB objects, it must use its private copies. It can not share them with uniGUI DB aware controls.


So i need to create new datamodule with a declaration of DB object (a copy) of uniGUI DB controls presents in mainmodule?

i can not do something like that (instantiate a private copy)

procedure servermodule.MyTimerTimer(Sender TObject);
  local_module: tunimainmodule;
 local_module := tunimainmodule.create(nil);

My seconde idea is to send a post message with parameters to server, using wget or curl command, to create a session...is this feasible?

my test is blocked by first responce of the server to the curl call. The server responde with 'loading ...' page (message from servermodule while loading first classes), and session is closed by client.


I'm looking for a way to get that goal , beacause i'm editing an existing project, with articulate units. Refactoring of simply duplicate some uints in order to call 2 function (that i need in timer event) seems to be so expensive. But there aren't an other way i should quickly start to code ;)




Link to comment
Share on other sites

You will not need any visual components in the servermodule anyway,

so any non-visual objects and code you want to share could be in a separate unit

with only such kind of code, used by both servermodule and mainmodule.


If you have any datasets in mainmodule you want to use, just copy them,

as well as the connection, and work with separate copies so you have some

kind of isolation between the server and the client mainmodules.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...