question

sergey.emantayev avatar image
3 0 1 2

OpenDACS: Should I check daemonConnectionState before calling login()?

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?

DACSopen-dacslog-in
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jirapongse avatar image
45.2k 103 43 60

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.

10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.