RE: [Asterisk-java-users] About the connectEvent
Brought to you by:
srt
From: King H. <kin...@ne...> - 2006-03-19 19:41:16
|
Below is the API doc that comes with A-J 0.3: -------------------------------------------------------------------------= ---------------------------------------- public class ConnectEvent extends ManagerEvent A ConnectEvent is triggered after successful login to the asterisk = server. It is a pseudo event not directly related to an asterisk = generated event.=20 -------------------------------------------------------------------------= ---------------------------------------- When the server is restarted, I need to know if we have auto-reconnected = AND login successfully back to the server. If yes, I'll start another = thread and send some actions to the server. Right now, I cannot tell = with a connectEvent is if the login is successful or not and sending = actions to the server may be bad. I hope this make sense. Thanks. King -----Original Message----- From: ast...@li... = [mailto:ast...@li...] On Behalf Of = Stefan Reuter Sent: Monday, March 20, 2006 1:13 AM To: ast...@li... Subject: Re: [Asterisk-java-users] About the connectEvent in this case it does what the api docs say (being triggered when connected to asterisk, not after authentication succeeded), right? are you in need of an event that is triggered upon successful authentication? if yes, why? (login() won't return until authentication either succeeded or failed, anyway) =3DStefan King Ho wrote: > Hi, >=20 > =20 >=20 > I think my description is incorrect!! >=20 > =20 >=20 > I think the connectEvent is sent every time, including the first = attempt, after a login(), whether it is successful or not. >=20 > =20 >=20 > Sorry about the confusion! >=20 > =20 >=20 > King >=20 > =20 >=20 > _____ =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 >=20 > =20 >=20 > Hi, >=20 > =20 >=20 > According to the api doc, the connectEvent should be sent after = successful login to the asterisk server. >=20 > =20 >=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 >=20 > failure and the program tries to login again. In my program I have = something like the following: >=20 > =20 >=20 > boolean authenticated =3D false; >=20 > while (!authenticated) { >=20 > try { >=20 > ManagerConnectionFactory factory =3D new = ManagerConnectionFactory( >=20 > address, port, login, password); >=20 > managerConnection.addEventHandler(this); >=20 > managerConnection =3D = factory.createManagerConnection(); >=20 > managerConnection.login(); >=20 > authenticated =3D true; >=20 > } catch (IOException e) { >=20 > Thread.sleep(5000); >=20 > } catch (TimeoutException e) { >=20 > Thread.sleep(5000); >=20 > } catch (AuthenticationFailedException e) { >=20 > Thread.sleep(5000); >=20 > } >=20 > } >=20 > =20 >=20 > If I have the login name or password incorrect, the connectEvent will = start coming in starting from the second >=20 > login attempt (no connectEvent is received during the first login = attempt). >=20 > =20 >=20 > I think receiving the connectEvent before successfully login to the = asterisk server is kind of useless as nothing can >=20 > be done until login is successful. >=20 > =20 >=20 > Thanks. >=20 > =20 >=20 > Best Regards, >=20 > =20 >=20 > King >=20 >=20 --=20 reuter network consulting Neusser Str. 110 50760 K=C3=B6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |