[Asterisk-java-users] About the connectEvent
Brought to you by:
srt
From: King H. <kin...@ne...> - 2006-03-19 16:21:31
|
=20 Hi, =20 According to the api doc, the connectEvent should be sent after = successful login to the asterisk server. =20 However, it seems that it will be sent whenever the driver is = reconnected to the asterisk server. This may be caused by an initial = login=20 failure and the program tries to login again. In my program I have = something like the following: =20 boolean authenticated =3D false; while (!authenticated) { try { ManagerConnectionFactory factory =3D new = ManagerConnectionFactory( address, port, login, password); managerConnection.addEventHandler(this); managerConnection =3D = factory.createManagerConnection(); managerConnection.login(); authenticated =3D true; } catch (IOException e) { Thread.sleep(5000); } catch (TimeoutException e) { Thread.sleep(5000); } catch (AuthenticationFailedException e) { Thread.sleep(5000); } } =20 If I have the login name or password incorrect, the connectEvent will = start coming in starting from the second login attempt (no connectEvent is received during the first login = attempt). =20 I think receiving the connectEvent before successfully login to the = asterisk server is kind of useless as nothing can be done until login is successful. =20 Thanks. =20 Best Regards, =20 King |