Following AuthorizationSystem::createAuthorizationAgent(), our code is monitoring AuthorizationAgent::daemonConnectionState() before calling login(). It proceeds to login() only after the state comes to authorizationConnectionUp. However the documentation does not mention checking the state. Sometimes the state is still authorizationConnectionPending even few seconds after the createAuthorizationAgent call. Is it mandatory to check the daemon connection state before calling login()? Is it safe to call login() if the state is still pending?
Yes, the code should check the daemonConnectionState before login().
If the application calls the login when the daemonConnectionState is not up, it may receive the following events.
12:13:21 Received DACS Authorization Event... User: user01 Position: 10.0.0.1/net Status: LoggedOut Status Code: AuthorizationSystemNotAvailable Status Text: DACS_UserLogin: Can't login User due to DACS Multiplexer connection down DACS Event stream closed
The event stream has been closed so the application needs to login again to open the stream.
In my opinion, it is not mandatory to check the daemon connection state before calling login() but it is nice to check it to avoid the re-login.
It is safe to call login() if the state is still pending. The key point is that the application needs to handle the stream state properly and check that if the login is opened/closed and LoggedIn/LoggedOut.