Project

General

Profile

Any way to wait for server event?

Added by Zach Motsinger over 8 years ago

I have a class that overwrites the WApplication class, and initializes a server. At this point CreateApplication is called in the server's entry point function, and during the application's constructor I try to log a user in with cookie based authentication using processEnvironment. The problem is, this event seems to take place before the URL is populated with the session id. (I have to use reload-is-new-session set to false for a variety of reasons) And thus, I am unable to interact with, or navigate away from, the home page until I hit the refresh button.

I assume this issue stems from the fact that I am logging in before the server finishes its initialization process. In the terminal, the login exchange takes place well before the "Wt: Refreshing session" prompt.

I have tried to override the WApplication::Initialize function to at least take the login event out of the constructor, but I get the same results. However, I am able to successfully bypass the problem by calling processEnvironment with a singleShot timer with a high enough wait time. But since the application and the server are likely running on different threads, this solution is probably not very reliable.

So, I am wondering if there is any official way to wait for the server to finish its initialization before I call processEnvironment. Mainly, I would like processEnvironment to be called only AFTER the URL has been populated with the session id. (Assuming this is the issue)

Any help or insight would be greatly appreciated!

Thanks!