RE: [Asterisk-java-users] About the connectEvent
Brought to you by:
srt
From: King H. <kin...@ne...> - 2006-03-19 16:44:30
|
Hi, =20 I think my description is incorrect!! =20 I think the connectEvent is sent every time, including the first = attempt, after a login(), whether it is successful or not. =20 Sorry about the confusion! =20 King =20 _____ =20 From: ast...@li... = [mailto:ast...@li...] On Behalf Of = King Ho Sent: Monday, March 20, 2006 12:21 AM To: ast...@li... Subject: [Asterisk-java-users] About the connectEvent =20 =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 |