Re: [Asterisk-java-users] Termination Status
Brought to you by:
srt
From: Martin S. <ma...@be...> - 2007-08-16 18:33:02
|
Hello Chuck, I think there's an issue with thread synchronization in Asterisk-Java at the moment. The Live API keeps track of a channel by unique ID, and AJ gets the failure event before the live API has recorded the unique of the channel -- the failure event ends up triggering a lookup by unique id, and can't find the channel yet. Hopefully that's a good explanation of the problem.=20 I recall that you can use an OriginateAction with .setAsync(Boolean.FALSE) if you are using the core part of the library, but I don't think there is an option for that in the live API yet. I hope I've explained that correctly, though I don't have a solution. Perhaps Stefan can comment more. Martin Smith, Systems Developer ma...@be... Bureau of Economic and Business Research University of Florida (352) 392-0171 Ext. 221=20 =20 > -----Original Message----- > From: ast...@li...=20 > [mailto:ast...@li...] On=20 > Behalf Of CHUCK SYPERSKI > Sent: Wednesday, August 15, 2007 3:02 PM > To: ast...@li... > Subject: Re: [Asterisk-java-users] Termination Status >=20 > Is there a way to detect if the line you just called is busy.=20 > When I dial a busy number I keep getting: >=20 > org.asteriskjava.live.NoSuchChannelException: Channel=20 > 'SIP/1xxxxxxxxxx@gafachi' is not available >=20 > Here is part of the code, its a bite ugly: >=20 > public void run() > { > fireEvent( D88CCEvent.CCTHREAD_BORN ); > try > { =09 > if ( login() ) > { > DefaultAsteriskServer server =3D=20 > new DefaultAsteriskServer( managerConnection ); > fireEvent(=20 > D88CCEvent.CCTHREAD_RINGING ); > String sp =3D ""; > if (=20 > task.getAsteriskServiceProvider() !=3D null &&=20 > task.getAsteriskServiceProvider().length() > 0 ) > sp =3D "@" +=20 > task.getAsteriskServiceProvider(); > =09 > channel =3D=20 > server.originateToExtension(task.getAsteriskTrunk() + "/" +=20 > task.getPhone() + sp, task.getAsteriskContext(),=20 > task.getExtension()+"", 1, task.getTimeOut() * 1000 ); >=20 > if ( channel !=3D null ) > { =09 > handleStateChange( channel ); > ChannelState oldState =3D null; > if ( channel.getState()=20 > =3D=3D ChannelState.UP || channel.getState() =3D=3D=20 > ChannelState.RINGING || channel.getState() =3D=3D ChannelState.RING ) > { > while(=20 > channel.getState() =3D=3D ChannelState.UP || channel.getState()=20 > =3D=3D ChannelState.RINGING || channel.getState() =3D=3D = ChannelState.RING ) > { > sleep(=20 > 100 ); =09 > } > =09 > if ( oldState=20 > !=3D channel.getState() ) > { > =09 > handleStateChange( channel );=09 > =09 > oldState =3D channel.getState(); > } > } > else > { > fireEvent(=20 > D88CCEvent.CCTHREAD_GENERAL_ERROR ); > lg(=20 > channel.toString() ); > System.exit( 1 ); > } > =09 > handleStateChange( channel );=09 > finalizeCall( channel ); > } > managerConnection.logoff(); > }=09 > =09 > } > catch( Exception e ) > {=09 > blComplete =3D true; >=20 > if ( e instanceof NoSuchChannelException ) > { > fireEvent(=20 > D88CCEvent.CCTHREAD_INVALIDNUMBER ); > System.err.println( e.toString() ); > e.printStackTrace(); > =09 > if ( channel !=3D null &&=20 > channel.wasBusy() ) > { > System.out.println(=20 > "Was Busy" ); > } > else > { > System.out.println(=20 > "Was NOT Busy" ); =09 > } =09 > =09 > System.out.println( e.getCause() ); > System.out.println( e.getMessage() ); > =09 > System.exit( 1 ); > } > else > { > intCompletionCode =3D=20 > D88CCEvent.CCTHREAD_DIED; > System.err.println( e.getMessage() ); > e.printStackTrace(); > //fireEvent( intCompletionCode );=09 > System.exit( 1 );=09 > } > } > =09 > } >=20 > >>> ma...@be... 08/15/07 11:52AM >>> > Hi Chuck, >=20 > I wish I had an answer to that question myself. I'm not sure there's a > way that is completely error-free, especially given an older=20 > generation > of answering machine that may do any number of things. >=20 > Is your project open source? >=20 > Martin Smith, Systems Developer > ma...@be...=20 > Bureau of Economic and Business Research > University of Florida > (352) 392-0171 Ext. 221=20 >=20 > =20 >=20 > > -----Original Message----- > > From: ast...@li...=20 > > [mailto:ast...@li...] On=20 > > Behalf Of CHUCK SYPERSKI > > Sent: Wednesday, August 15, 2007 12:02 PM > > To: ast...@li...=20 > > Subject: [Asterisk-java-users] Termination Status > >=20 > > I am in the process of testing a autodialer I wrote for a=20 > > school district. Basically what I do is make an outgoing=20 > > call via a gafachi sip trunk and connect the user to an=20 > > internal extension that plays a message and hangs up. =20 > > Everything works great, but I wanted to know if there is=20 > > anyway that I can tell if I have called a fax machine, or=20 > > voicemail. Right now I am using the live package and I am=20 > > using the AsteriskChannel.getState() and using the=20 > > HangupCause enumeration. Thanks so much for any help that=20 > > can be provided and thanks for writting a great api. > >=20 > > Thanks, > > Chuck Syperski > > DuPage High School District 88 > >=20 > >=20 > > -------------------------------------------------------------- > > ----------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and=20 > > a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/=20 > > _______________________________________________ > > Asterisk-java-users mailing list > > Ast...@li...=20 > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users=20 > >=20 >=20 > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and=20 > a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/=20 > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li...=20 > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >=20 > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and=20 > a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >=20 |