Thread: [Asterisk-java-users] How to get ORIGINATE_STATUS value after OriginateAction
Brought to you by:
srt
|
From: roko <ro...@ya...> - 2013-03-04 03:06:55
|
Hi everyone I'm just starting with asterisk and asterisk-java, so please forgive me if this is a silly question. Here (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate) I can see that the originate cmd sets the ORIGINATE_STATUS variable before exiting. How can I get this value from asterisk-java ? At this point I'm using the code from the tutorial, like this: OriginateAction originateAction; ManagerResponse originateResponse; originateAction = new OriginateAction(); originateAction.setChannel("SIP/John"); originateAction.setContext("default"); originateAction.setExten("1300"); originateAction.setPriority(new Integer(1)); originateAction.setTimeout(new Integer(30000)); managerConnection.login(); originateResponse = managerConnection.sendAction(originateAction, 30000); Thx for your help. E. |
|
From: Yves A. <yv...@gm...> - 2013-03-04 07:46:00
|
Hi, you could use a callback handler. this way you´ll get informed about any state change. yves Am 04.03.2013 04:06, schrieb roko: > Hi everyone > > I'm just starting with asterisk and asterisk-java, so please forgive > me if this is a silly question. Here > (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate) > <http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate> I can see > that the originate cmd sets the ORIGINATE_STATUS variable before > exiting. How can I get this value from asterisk-java ? At this point > I'm using the code from the tutorial, like this: > OriginateAction originateAction; > ManagerResponse originateResponse; > > originateAction = new OriginateAction(); > originateAction.setChannel("SIP/John"); > originateAction.setContext("default"); > originateAction.setExten("1300"); > originateAction.setPriority(new Integer(1)); > originateAction.setTimeout(new Integer(30000)); > > managerConnection.login(); > originateResponse = managerConnection.sendAction(originateAction, 30000); > Thx for your help. > > E. > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |
|
From: roko <ro...@ya...> - 2013-03-04 15:38:08
|
Hi
Thx for your answer. Do you mean instead of blocking using:
ManagerResponse sendAction(ManagerAction action, long timeout)
Should I use this function ?:
void sendAction(ManagerAction action, SendActionCallback callback)
I see in the docs that I still get a ManagerResponse. Pls forgive me, I'm very new at this. How can I get the ORIGINATE_STATUS from the ManagerResponse object ? Do you have an example that I could use ? Thx for your help.
E.
________________________________
De: Yves A. <yv...@gm...>
Para: ast...@li...
Enviado: Lunes, 4 de marzo, 2013 2:45 A.M.
Asunto: Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value after OriginateAction
Hi,
you could use a callback handler. this way you´ll get informed
about any state change.
yves
Am 04.03.2013 04:06, schrieb roko:
Hi everyone
>
>
>I'm just starting with asterisk and asterisk-java, so please forgive me if this is a silly question. Here (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate) I can see that the originate cmd sets the ORIGINATE_STATUS variable before exiting. How can I get this value from asterisk-java ? At this point I'm using the code from the tutorial, like this:
>OriginateAction originateAction; ManagerResponse originateResponse; originateAction = new OriginateAction(); originateAction.setChannel("SIP/John"); originateAction.setContext("default"); originateAction.setExten("1300"); originateAction.setPriority(new Integer(1)); originateAction.setTimeout(new Integer(30000)); managerConnection.login(); originateResponse = managerConnection.sendAction(originateAction, 30000);
>Thx for your help.
>
>
> E.
>
>
>
>------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb
>
>
>_______________________________________________
Asterisk-java-users mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Asterisk-java-users mailing list
Ast...@li...
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |
|
From: roko <ro...@ya...> - 2013-03-06 03:57:20
|
Hi
I use the SendActionCallback, but I'm getting the same response that I get from the blocking function... no new data. So, how can I get the value of the ORIGINATE_STATUS variable ?
E.
________________________________
De: roko <ro...@ya...>
Para: "ast...@li..." <ast...@li...>
Enviado: Lunes, 4 de marzo, 2013 10:38 A.M.
Asunto: Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value after OriginateAction
Hi
Thx for your answer. Do you mean instead of blocking using:
ManagerResponse sendAction(ManagerAction action, long timeout)
Should I use this function ?:
void sendAction(ManagerAction action, SendActionCallback callback)
I see in the docs that I still get a ManagerResponse. Pls forgive me, I'm very new at this. How can I get the ORIGINATE_STATUS from the ManagerResponse object ? Do you have an example that I could use ? Thx for your help.
E.
________________________________
De: Yves A. <yv...@gm...>
Para: ast...@li...
Enviado: Lunes, 4 de marzo, 2013 2:45 A.M.
Asunto: Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value after OriginateAction
Hi,
you could use a callback handler. this way you´ll get informed
about any state change.
yves
Am 04.03.2013 04:06, schrieb roko:
Hi everyone
>
>
>I'm just starting with asterisk and asterisk-java, so please forgive me if this is a silly question. Here (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate) I can see that the originate cmd sets the ORIGINATE_STATUS variable before exiting. How can I get this value from asterisk-java ? At this point I'm using the code from the tutorial, like this:
>OriginateAction originateAction; ManagerResponse originateResponse; originateAction = new OriginateAction(); originateAction.setChannel("SIP/John"); originateAction.setContext("default"); originateAction.setExten("1300"); originateAction.setPriority(new Integer(1)); originateAction.setTimeout(new Integer(30000)); managerConnection.login(); originateResponse = managerConnection.sendAction(originateAction, 30000);
>Thx for your help.
>
>
> E.
>
>
>
>------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb
>
>
>_______________________________________________
Asterisk-java-users mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Asterisk-java-users mailing list
Ast...@li...
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Asterisk-java-users mailing list
Ast...@li...
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |
|
From: Yves A. <yv...@gm...> - 2013-03-06 11:38:25
|
hi,
pls. see attached source...
package tests;
import org.asteriskjava.live.AsteriskChannel;
import org.asteriskjava.live.DefaultAsteriskServer;
import org.asteriskjava.live.LiveException;
import org.asteriskjava.live.OriginateCallback;
import org.asteriskjava.manager.ManagerConnection;
import org.asteriskjava.manager.action.OriginateAction;
public class CallTestWithCallbackHandler {
private static ManagerConnection managerConnection;
public static void main(String[] args) throws Exception{
DefaultAsteriskServer asteriskServer = new
DefaultAsteriskServer("SERVER", "USER", "PASSWORD");
asteriskServer.getManagerConnection().login();
try {
OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("SIP/177");//first leg
originateAction.setContext("from-internal");
originateAction.setExten("08154711"); //second leg
originateAction.setPriority(1);
originateAction.setTimeout(15000);
asteriskServer.originateAsync(originateAction, new
myCallbackHandler("177"));
System.out.println("now idling for a minute to get a
chance to receive events and states...");
try {
Thread.sleep(60000);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
package tests;
import org.asteriskjava.live.AsteriskChannel;
import org.asteriskjava.live.LiveException;
import org.asteriskjava.live.OriginateCallback;
public class myCallbackHandler implements OriginateCallback{
public String reference;
public myCallbackHandler(String reference){
System.out.println("myCallbackHandler for reference
"+reference+" just instantiated.");
this.reference = reference;
}
public void onDialing(AsteriskChannel ac)
{
System.out.println("myCallbackHandler for reference
"+reference+" receives state: Dialling, channelID is: "+ac.getId()+",
State is: "+ac.getState());
String channelID=ac.getId();
}
public void onBusy(AsteriskChannel ac)
{
System.out.println("myCallbackHandler for reference
"+reference+" receives state: Busy, channelID is: "+ac.getId()+", State
is: "+ac.getState());
}
public void onFailure(LiveException le)
{
System.out.println("myCallbackHandler for reference
"+reference+" receives state: Failure "+le.getMessage());
}
public void onNoAnswer(AsteriskChannel ac)
{
System.out.println("myCallbackHandler for reference
"+reference+" receives state: No Answer, channelID is: "+ac.getId()+",
State is: "+ac.getState());
}
public void onSuccess(AsteriskChannel ac)
{
System.out.println("myCallbackHandler for reference
"+reference+" receives state: Success, channelID is: "+ac.getId()+",
State is: "+ac.getState());
}
}
regards,
yves
Am 06.03.2013 04:57, schrieb roko:
> Hi
>
> I use the SendActionCallback, but I'm getting the same response that I
> get from the blocking function... no new data. So, how can I get the
> value of the ORIGINATE_STATUS variable ?
>
> E.
>
> ------------------------------------------------------------------------
> *De:* roko <ro...@ya...>
> *Para:* "ast...@li..."
> <ast...@li...>
> *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M.
> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value
> after OriginateAction
>
> Hi
>
> Thx for your answer. Do you mean instead of blocking using:
>
> ManagerResponse
> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html> sendAction(ManagerAction
> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
> long timeout)
>
> Should I use this function ?:
>
> void sendAction(ManagerAction
> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
> SendActionCallback
> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html> callback)
>
> I see in the docs that I still get a ManagerResponse
> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>.
> Pls forgive me, I'm very new at this. How can I get the
> ORIGINATE_STATUS from the ManagerResponse object ? Do you have an
> example that I could use ? Thx for your help.
>
> E.
>
> ------------------------------------------------------------------------
> *De:* Yves A. <yv...@gm...>
> *Para:* ast...@li...
> *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M.
> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value
> after OriginateAction
>
> Hi,
>
> you could use a callback handler. this way you´ll get informed about
> any state change.
>
> yves
>
> Am 04.03.2013 04:06, schrieb roko:
>> Hi everyone
>>
>> I'm just starting with asterisk and asterisk-java, so please forgive
>> me if this is a silly question. Here
>> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate)
>> <http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate> I can see
>> that the originate cmd sets the ORIGINATE_STATUS variable before
>> exiting. How can I get this value from asterisk-java ? At this point
>> I'm using the code from the tutorial, like this:
>> OriginateAction originateAction;
>> ManagerResponse originateResponse;
>>
>> originateAction = new OriginateAction();
>> originateAction.setChannel("SIP/John");
>> originateAction.setContext("default");
>> originateAction.setExten("1300");
>> originateAction.setPriority(new Integer(1));
>> originateAction.setTimeout(new Integer(30000));
>>
>> managerConnection.login();
>> originateResponse = managerConnection.sendAction(originateAction, 30000);
>> Thx for your help.
>>
>> E.
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>>
>>
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li... <mailto:Ast...@li...>
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> <mailto:Ast...@li...>
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> <mailto:Ast...@li...>
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
>
>
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
|
|
From: Mordechay K. <mka...@gm...> - 2013-03-06 12:23:19
|
B.H.
Hi
There is indeed some problem with OriginateAction events - but it seems to
be asterisk's problem. When i send OriginateAction (in async mode, but this
doesn't really matter AFAIK), asterisk immediately create a channel and
starts to ring while it do generate all related AMI events like
NewChannelEvent, NewStateEvent on that channel, but until the call
is established or failed the AMI listener is unable to link between the
OriginateAction and the new channel. Only OriginateResponseEvent will
contain both OriginateAction's id and the newly created channel. This means
that there's no way to get status updates on ongoing originate action like
see if the channel is ringing or dialing or whatever, even that the same
app "sees" the new channel and it's status updates.
At least, that's what i have learned from my experience. Maybe somebody
knows how to workaround this?
On Wed, Mar 6, 2013 at 1:38 PM, Yves A. <yv...@gm...> wrote:
> hi,
>
> pls. see attached source...
>
>
> package tests;
>
>
> import org.asteriskjava.live.AsteriskChannel;
> import org.asteriskjava.live.DefaultAsteriskServer;
> import org.asteriskjava.live.LiveException;
> import org.asteriskjava.live.OriginateCallback;
> import org.asteriskjava.manager.ManagerConnection;
> import org.asteriskjava.manager.action.OriginateAction;
>
>
> public class CallTestWithCallbackHandler {
>
> private static ManagerConnection managerConnection;
>
> public static void main(String[] args) throws Exception{
>
> DefaultAsteriskServer asteriskServer = new
> DefaultAsteriskServer("SERVER", "USER", "PASSWORD");
> asteriskServer.getManagerConnection().login();
>
>
> try {
> OriginateAction originateAction = new OriginateAction();
> originateAction.setChannel("SIP/177"); //first leg
> originateAction.setContext("from-internal");
> originateAction.setExten("08154711"); //second leg
> originateAction.setPriority(1);
> originateAction.setTimeout(15000);
> asteriskServer.originateAsync(originateAction, new
> myCallbackHandler("177"));
> System.out.println("now idling for a minute to get a
> chance to receive events and states...");
> try {
> Thread.sleep(60000);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
> }
>
>
>
> package tests;
>
> import org.asteriskjava.live.AsteriskChannel;
> import org.asteriskjava.live.LiveException;
> import org.asteriskjava.live.OriginateCallback;
>
> public class myCallbackHandler implements OriginateCallback{
>
>
> public String reference;
>
> public myCallbackHandler(String reference){
> System.out.println("myCallbackHandler for reference "+reference+"
> just instantiated.");
> this.reference = reference;
> }
>
> public void onDialing(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference "+reference+"
> receives state: Dialling, channelID is: "+ac.getId()+", State is:
> "+ac.getState());
>
> String channelID=ac.getId();
> }
>
> public void onBusy(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference "+reference+"
> receives state: Busy, channelID is: "+ac.getId()+", State is:
> "+ac.getState());
> }
>
> public void onFailure(LiveException le)
> {
> System.out.println("myCallbackHandler for reference "+reference+"
> receives state: Failure "+le.getMessage());
> }
>
> public void onNoAnswer(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference "+reference+"
> receives state: No Answer, channelID is: "+ac.getId()+", State is:
> "+ac.getState());
> }
>
> public void onSuccess(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference "+reference+"
> receives state: Success, channelID is: "+ac.getId()+", State is:
> "+ac.getState());
> }
>
> }
>
>
> regards,
> yves
>
>
> Am 06.03.2013 04:57, schrieb roko:
>
> Hi
>
> I use the SendActionCallback, but I'm getting the same response that I get
> from the blocking function... no new data. So, how can I get the value of
> the ORIGINATE_STATUS variable ?
>
> E.
>
> ------------------------------
> *De:* roko <ro...@ya...> <ro...@ya...>
> *Para:* "ast...@li..."<ast...@li...>
> <ast...@li...><ast...@li...>
> *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M.
> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value
> after OriginateAction
>
> Hi
>
> Thx for your answer. Do you mean instead of blocking using:
>
> ManagerResponse<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>
> sendAction(ManagerAction<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
> long timeout)
>
> Should I use this function ?:
>
> void sendAction(ManagerAction<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
> SendActionCallback<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html>
> callback)
>
> I see in the docs that I still get a ManagerResponse<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>.
> Pls forgive me, I'm very new at this. How can I get the ORIGINATE_STATUS
> from the ManagerResponse object ? Do you have an example that I could use
> ? Thx for your help.
>
> E.
>
> ------------------------------
> *De:* Yves A. <yv...@gm...> <yv...@gm...>
> *Para:* ast...@li...
> *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M.
> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value
> after OriginateAction
>
> Hi,
>
> you could use a callback handler. this way you´ll get informed about any
> state change.
>
> yves
>
> Am 04.03.2013 04:06, schrieb roko:
>
> Hi everyone
>
> I'm just starting with asterisk and asterisk-java, so please forgive me
> if this is a silly question. Here
> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate)<http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate>I can see that the originate cmd sets the ORIGINATE_STATUS variable before
> exiting. How can I get this value from asterisk-java ? At this point I'm
> using the code from the tutorial, like this:
>
> OriginateAction originateAction;
> ManagerResponse originateResponse;
>
> originateAction = new OriginateAction();
> originateAction.setChannel("SIP/John");
> originateAction.setContext("default");
> originateAction.setExten("1300");
> originateAction.setPriority(new Integer(1));
> originateAction.setTimeout(new Integer(30000));
>
> managerConnection.login();
> originateResponse = managerConnection.sendAction(originateAction, 30000);
>
> Thx for your help.
>
> E.
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:http://p.sf.net/sfu/appdyn_d2d_feb
>
>
>
> _______________________________________________
> Asterisk-java-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev
>
>
>
> _______________________________________________
> Asterisk-java-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
--
משיח NOW!
Moshiach is coming very soon, prepare yourself!
יחי אדוננו מורינו ורבינו מלך המשיח לעולם ועד!
|
|
From: Yves A. <yv...@gm...> - 2013-03-06 14:56:30
|
maybe we talk about different things, but if i run my given code, i can
see status updates via callbackhandler...
I agree, that there is obviously no way to _immediately_ get the
channelID via asynchronous dial, but thats
no problem, because you can pass your own references to the
callbackhandler constructor. In my example it
is a simple string, but you could pass any other object there..
if your listening to ami events only, you could match the value of the
channel (event.getChannel) against the
"number" you dialed and can track any state of your call this way....
(but i admit... there are nuts and bolts...
redirecting calls, ringgroups, followme, local channels, queues and so
on can make track a call quite hard...)
the following example uses callbackhandler plus eventlisteners to get
all information in realtime:
package tests;
import org.asteriskjava.live.AsteriskChannel;
import org.asteriskjava.live.AsteriskQueueEntry;
import org.asteriskjava.live.AsteriskServerListener;
import org.asteriskjava.live.DefaultAsteriskServer;
import org.asteriskjava.live.MeetMeUser;
import org.asteriskjava.live.internal.AsteriskAgentImpl;
import org.asteriskjava.manager.ManagerConnection;
import org.asteriskjava.manager.ManagerEventListener;
import org.asteriskjava.manager.action.OriginateAction;
import org.asteriskjava.manager.event.BridgeEvent;
import org.asteriskjava.manager.event.ChannelUpdateEvent;
import org.asteriskjava.manager.event.DialEvent;
import org.asteriskjava.manager.event.HangupEvent;
import org.asteriskjava.manager.event.LinkEvent;
import org.asteriskjava.manager.event.ManagerEvent;
import org.asteriskjava.manager.event.NewAccountCodeEvent;
import org.asteriskjava.manager.event.NewCallerIdEvent;
import org.asteriskjava.manager.event.NewChannelEvent;
import org.asteriskjava.manager.event.NewStateEvent;
import org.asteriskjava.manager.event.OriginateFailureEvent;
import org.asteriskjava.manager.event.OriginateResponseEvent;
import org.asteriskjava.manager.event.OriginateSuccessEvent;
import org.asteriskjava.manager.event.UnlinkEvent;
public class CallTestWithCallbackHandler implements
AsteriskServerListener, ManagerEventListener{
private static ManagerConnection managerConnection;
public CallTestWithCallbackHandler() throws Exception{
DefaultAsteriskServer asteriskServer = new
DefaultAsteriskServer("SERVER", "USERNAME", "PASSWORD");
asteriskServer.getManagerConnection().login();
asteriskServer.addAsteriskServerListener(this);
asteriskServer.getManagerConnection().addEventListener(this);
try {
OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("DAHDI/g0/SOURCENUMBERHERE");
originateAction.setContext("from-sip");
originateAction.setExten("DESTINATIONNUMBERHERE");
originateAction.setPriority(1);
originateAction.setTimeout(15000l);
asteriskServer.originateAsync(originateAction, new
myCallbackHandler("TESTCALL"));
System.out.println("now idling for a minute to get a
chance to receive events and states...");
try {
Thread.sleep(60000);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) throws Exception{
CallTestWithCallbackHandler aCall = new
CallTestWithCallbackHandler();
}
@Override
public void onNewAsteriskChannel(AsteriskChannel channel) {
System.out.println("new Channel created... data is: "+channel);
}
@Override
public void onNewMeetMeUser(MeetMeUser user) {
}
@Override
public void onNewAgent(AsteriskAgentImpl agent) {
}
@Override
public void onNewQueueEntry(AsteriskQueueEntry entry) {
}
@Override
public void onManagerEvent(ManagerEvent event) {
// only print out relevant events here..
if (event instanceof NewChannelEvent
|| event instanceof ChannelUpdateEvent
|| event instanceof OriginateResponseEvent
|| event instanceof OriginateFailureEvent
|| event instanceof OriginateSuccessEvent
|| event instanceof NewCallerIdEvent
|| event instanceof NewStateEvent
|| event instanceof LinkEvent
|| event instanceof UnlinkEvent
|| event instanceof BridgeEvent
|| event instanceof DialEvent
|| event instanceof HangupEvent)
System.out.println("got Event: "+event);
}
}
an execution prints out, what happens in detail during a call setup, the
call itself and the hangup..
output of callbackhandler is blue, managerevents are red, serverevents
are violet and important details are _*black,bold and underlined*_...
with this trace you can see very well, what happens at which time...
myCallbackHandler for reference TESTCALL just instantiated.
now idling for a minute to get a chance to receive events and states...
got Event:
org.asteriskjava.manager.event._*NewChannelEvent*_[dateReceived='Wed Mar
06 15:30:02 CET
2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Rsrvd*_',channelstate='1',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Rsrvd',systemHashcode=1564136253]
got Event:
org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed Mar
06 15:30:02 CET
2013',privilege='call,all',callerid=null,sequencenumber=null,state='Dialing',channelstate='3',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Dialing',systemHashcode=959993440]
myCallbackHandler for reference TESTCALL receives state: Dialling,
channelID is: *_1362580137.4260_*, State is: RSRVD
new Channel created... data is:
AsteriskChannel[id='_*1362580137.4260*_',name='DAHDI/i1/SOURCENUMBERHERE-24d',callerId='',state='RSRVD',account='null',dateOfCreation=Wed
Mar 06 15:30:02 CET
2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
got Event:
org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed Mar
06 15:30:05 CET
2013',privilege='call,all',callerid=null,sequencenumber=null,state='*_Ringing_*',channelstate='5',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Ringing',systemHashcode=591210723]
got Event:
org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed Mar
06 15:30:07 CET
2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Up*_',channelstate='6',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Up',systemHashcode=1084010740]
got Event:
org.asteriskjava.manager.event._*OriginateResponseEvent*_[dateReceived='Wed
Mar 06 15:30:07 CET
2013',privilege='call,all',sequencenumber=null,reason='4',response='_*Success*_',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',actionid='AJ_ORIGINATE_0',internalactionid='569616903_9',context='from-sip',exten='DESTINATIONNUMBERHERE',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1864729679]
myCallbackHandler for reference TESTCALL receives state: Success,
channelID is: _*1362580137.4260*_, State is: _*UP*_
got Event:
org.asteriskjava.manager.event._*NewChannelEvent*_[dateReceived='Wed Mar
06 15:30:07 CET
2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Rsrvd*_',channelstate='1',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Rsrvd',systemHashcode=198249052]
got Event:
org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed Mar
06 15:30:07 CET
2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='_*Dialing*_',channelstate='3',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Dialing',systemHashcode=1832874625]
got Event:
org.asteriskjava.manager.event._*DialEvent*_[dateReceived='Wed Mar 06
15:30:07 CET
2013',privilege='call,all',subevent='Begin',callerid=null,dialstatus=null,sequencenumber=null,_*destuniqueid='1362580141.4261',srcuniqueid='1362580137.4260'*_,destination='DAHDI/i1/DESTINATIONNUMBERHERE-24e',dialstring='g0/DESTINATIONNUMBERHERE',timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1000613778]
new Channel created... data is:
AsteriskChannel[_*id='1362580141.4261'*_,name='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerId='',state='_*RSRVD*_',account='null',dateOfCreation=Wed
Mar 06 15:30:07 CET
2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
got Event:
org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed Mar
06 15:30:12 CET
2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='_*Ringing*_',channelstate='5',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Ringing',systemHashcode=158635208]
got Event:
org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed Mar
06 15:30:14 CET
2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Up*_',channelstate='6',calleridname=null,timestamp=null,uniqueid='*_1362580141.4261_*',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Up',systemHashcode=1232704349]
got Event:
org.asteriskjava.manager.event._*BridgeEvent*_[dateReceived='Wed Mar 06
15:30:14 CET
2013',privilege='call,all',_*uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*_,sequencenumber=null,bridgestate='_*Link*_',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=45104096]
got Event:
org.asteriskjava.manager.event._*BridgeEvent*_[dateReceived='Wed Mar 06
15:30:17 CET
2013',privilege='call,all',_*uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*_,sequencenumber=null,bridgestate='_*Unlink*_',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=277466206]
got Event:
org.asteriskjava.manager.event._*HangupEvent*_[dateReceived='Wed Mar 06
15:30:17 CET 2013',privilege='call,all',causetxt='Normal
Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',systemHashcode=2110683211]
got Event:
org.asteriskjava.manager.event._*DialEvent*_[dateReceived='Wed Mar 06
15:30:17 CET
2013',privilege='call,all',subevent='End',callerid=null,dialstatus='*_ANSWER_*',sequencenumber=null,destuniqueid=null,srcuniqueid='*_1362580137.4260_*',destination=null,dialstring=null,timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1501740254]
got Event:
org.asteriskjava.manager.event._*HangupEvent*_[dateReceived='Wed Mar 06
15:30:17 CET 2013',privilege='call,all',causetxt='Normal
Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=373145787]
regards,
yves
Am 06.03.2013 13:23, schrieb Mordechay Kaganer:
> B.H.
>
> Hi
>
> There is indeed some problem with OriginateAction events - but it
> seems to be asterisk's problem. When i send OriginateAction (in async
> mode, but this doesn't really matter AFAIK), asterisk immediately
> create a channel and starts to ring while it do generate all related
> AMI events like NewChannelEvent, NewStateEvent on that channel, but
> until the call is established or failed the AMI listener is unable to
> link between the OriginateAction and the new channel.
> Only OriginateResponseEvent will contain both OriginateAction's id and
> the newly created channel. This means that there's no way to get
> status updates on ongoing originate action like see if the channel is
> ringing or dialing or whatever, even that the same app "sees" the new
> channel and it's status updates.
>
> At least, that's what i have learned from my experience. Maybe
> somebody knows how to workaround this?
>
>
> On Wed, Mar 6, 2013 at 1:38 PM, Yves A. <yv...@gm...
> <mailto:yv...@gm...>> wrote:
>
> hi,
>
> pls. see attached source...
>
>
> package tests;
>
>
> import org.asteriskjava.live.AsteriskChannel;
> import org.asteriskjava.live.DefaultAsteriskServer;
> import org.asteriskjava.live.LiveException;
> import org.asteriskjava.live.OriginateCallback;
> import org.asteriskjava.manager.ManagerConnection;
> import org.asteriskjava.manager.action.OriginateAction;
>
>
> public class CallTestWithCallbackHandler {
>
> private static ManagerConnection managerConnection;
>
> public static void main(String[] args) throws Exception{
>
> DefaultAsteriskServer asteriskServer = new
> DefaultAsteriskServer("SERVER", "USER", "PASSWORD");
> asteriskServer.getManagerConnection().login();
>
>
> try {
> OriginateAction originateAction = new
> OriginateAction();
> originateAction.setChannel("SIP/177");//first leg
> originateAction.setContext("from-internal");
> originateAction.setExten("08154711"); //second leg
> originateAction.setPriority(1);
> originateAction.setTimeout(15000);
> asteriskServer.originateAsync(originateAction, new
> myCallbackHandler("177"));
> System.out.println("now idling for a minute to get
> a chance to receive events and states...");
> try {
> Thread.sleep(60000);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
> }
>
>
>
> package tests;
>
> import org.asteriskjava.live.AsteriskChannel;
> import org.asteriskjava.live.LiveException;
> import org.asteriskjava.live.OriginateCallback;
>
> public class myCallbackHandler implements OriginateCallback{
>
>
> public String reference;
>
> public myCallbackHandler(String reference){
> System.out.println("myCallbackHandler for reference
> "+reference+" just instantiated.");
> this.reference = reference;
> }
>
> public void onDialing(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference
> "+reference+" receives state: Dialling, channelID is:
> "+ac.getId()+", State is: "+ac.getState());
>
> String channelID=ac.getId();
> }
>
> public void onBusy(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference
> "+reference+" receives state: Busy, channelID is: "+ac.getId()+",
> State is: "+ac.getState());
> }
>
> public void onFailure(LiveException le)
> {
> System.out.println("myCallbackHandler for reference
> "+reference+" receives state: Failure "+le.getMessage());
> }
>
> public void onNoAnswer(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference
> "+reference+" receives state: No Answer, channelID is:
> "+ac.getId()+", State is: "+ac.getState());
> }
>
> public void onSuccess(AsteriskChannel ac)
> {
> System.out.println("myCallbackHandler for reference
> "+reference+" receives state: Success, channelID is:
> "+ac.getId()+", State is: "+ac.getState());
> }
>
> }
>
>
> regards,
> yves
>
>
> Am 06.03.2013 04:57, schrieb roko:
>> Hi
>>
>> I use the SendActionCallback, but I'm getting the same response
>> that I get from the blocking function... no new data. So, how
>> can I get the value of the ORIGINATE_STATUS variable ?
>>
>> E.
>>
>> ------------------------------------------------------------------------
>> *De:* roko <ro...@ya...> <mailto:ro...@ya...>
>> *Para:* "ast...@li..."
>> <mailto:ast...@li...>
>> <ast...@li...>
>> <mailto:ast...@li...>
>> *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M.
>> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS
>> value after OriginateAction
>>
>> Hi
>>
>> Thx for your answer. Do you mean instead of blocking using:
>>
>> ManagerResponse
>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html> sendAction(ManagerAction
>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>> long timeout)
>>
>> Should I use this function ?:
>>
>> void sendAction(ManagerAction
>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>> SendActionCallback
>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html> callback)
>>
>> I see in the docs that I still get a ManagerResponse
>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>.
>> Pls forgive me, I'm very new at this. How can I get the
>> ORIGINATE_STATUS from the ManagerResponse object ? Do you have an
>> example that I could use ? Thx for your help.
>>
>> E.
>>
>> ------------------------------------------------------------------------
>> *De:* Yves A. <yv...@gm...> <mailto:yv...@gm...>
>> *Para:* ast...@li...
>> <mailto:ast...@li...>
>> *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M.
>> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS
>> value after OriginateAction
>>
>> Hi,
>>
>> you could use a callback handler. this way you´ll get informed
>> about any state change.
>>
>> yves
>>
>> Am 04.03.2013 04:06, schrieb roko:
>>> Hi everyone
>>>
>>> I'm just starting with asterisk and asterisk-java, so please
>>> forgive me if this is a silly question. Here
>>> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate)
>>> <http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate> I
>>> can see that the originate cmd sets the ORIGINATE_STATUS
>>> variable before exiting. How can I get this value from
>>> asterisk-java ? At this point I'm using the code from the
>>> tutorial, like this:
>>> OriginateAction originateAction;
>>> ManagerResponse originateResponse;
>>>
>>> originateAction = new OriginateAction();
>>> originateAction.setChannel("SIP/John");
>>> originateAction.setContext("default");
>>> originateAction.setExten("1300");
>>> originateAction.setPriority(new Integer(1));
>>> originateAction.setTimeout(new Integer(30000));
>>>
>>> managerConnection.login();
>>> originateResponse = managerConnection.sendAction(originateAction, 30000);
>>> Thx for your help.
>>>
>>> E.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Everyone hates slow websites. So do we.
>>> Make your web apps faster with AppDynamics
>>> Download AppDynamics Lite for free today:
>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>
>>>
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> Ast...@li... <mailto:Ast...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li...
>> <mailto:Ast...@li...>
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li...
>> <mailto:Ast...@li...>
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, access the full report.
>> http://p.sf.net/sfu/symantec-dev2dev
>>
>>
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li... <mailto:Ast...@li...>
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The
> Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice"
> in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> <mailto:Ast...@li...>
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> --
> ???? NOW!
> Moshiach is coming very soon, prepare yourself!
> ??? ?????? ?????? ?????? ??? ????? ????? ???!
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
>
>
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
|
|
From: Mordechay K. <mka...@gm...> - 2013-03-06 15:18:04
|
B.H.
Yves, thanks for the testing and the logs :-). That's exactly what i meant.
At least in relation to dialing real PSTN numbers, matching the call by the
dialed phone number will be a bad idea because it's not really unique.
Theoretically, it's perfectly OK to dial the same number several times in
parallel, at least if the destination is some kind of office PBX or IVR e
t.c.
Maybe, to workaround it will be possible to dial to "local" channel,
answer() the call and then dial out from the dialplan. Then OriginateAction
will always succeed almost immediately and then application will be able to
track the actual dial out process by tracking the bridged channel. But IMHO
it will require a lot of resources and not really practical with
significant call volumes.
Thanks for the advice, anyway :-)
On Wed, Mar 6, 2013 at 4:56 PM, Yves A. <yv...@gm...> wrote:
> maybe we talk about different things, but if i run my given code, i can
> see status updates via callbackhandler...
> I agree, that there is obviously no way to _immediately_ get the channelID
> via asynchronous dial, but thats
> no problem, because you can pass your own references to the
> callbackhandler constructor. In my example it
> is a simple string, but you could pass any other object there..
> if your listening to ami events only, you could match the value of the
> channel (event.getChannel) against the
> "number" you dialed and can track any state of your call this way.... (but
> i admit... there are nuts and bolts...
> redirecting calls, ringgroups, followme, local channels, queues and so on
> can make track a call quite hard...)
>
> the following example uses callbackhandler plus eventlisteners to get all
> information in realtime:
>
> package tests;
>
>
> import org.asteriskjava.live.AsteriskChannel;
> import org.asteriskjava.live.AsteriskQueueEntry;
> import org.asteriskjava.live.AsteriskServerListener;
> import org.asteriskjava.live.DefaultAsteriskServer;
> import org.asteriskjava.live.MeetMeUser;
> import org.asteriskjava.live.internal.AsteriskAgentImpl;
> import org.asteriskjava.manager.ManagerConnection;
> import org.asteriskjava.manager.ManagerEventListener;
> import org.asteriskjava.manager.action.OriginateAction;
> import org.asteriskjava.manager.event.BridgeEvent;
> import org.asteriskjava.manager.event.ChannelUpdateEvent;
> import org.asteriskjava.manager.event.DialEvent;
> import org.asteriskjava.manager.event.HangupEvent;
> import org.asteriskjava.manager.event.LinkEvent;
> import org.asteriskjava.manager.event.ManagerEvent;
> import org.asteriskjava.manager.event.NewAccountCodeEvent;
> import org.asteriskjava.manager.event.NewCallerIdEvent;
> import org.asteriskjava.manager.event.NewChannelEvent;
> import org.asteriskjava.manager.event.NewStateEvent;
> import org.asteriskjava.manager.event.OriginateFailureEvent;
> import org.asteriskjava.manager.event.OriginateResponseEvent;
> import org.asteriskjava.manager.event.OriginateSuccessEvent;
> import org.asteriskjava.manager.event.UnlinkEvent;
>
>
> public class CallTestWithCallbackHandler implements
> AsteriskServerListener, ManagerEventListener{
>
> private static ManagerConnection managerConnection;
>
> public CallTestWithCallbackHandler() throws Exception{
>
> DefaultAsteriskServer asteriskServer = new
> DefaultAsteriskServer("SERVER", "USERNAME", "PASSWORD");
> asteriskServer.getManagerConnection().login();
> asteriskServer.addAsteriskServerListener(this);
> asteriskServer.getManagerConnection().addEventListener(this);
>
>
>
> try {
> OriginateAction originateAction = new OriginateAction();
> originateAction.setChannel("DAHDI/g0/SOURCENUMBERHERE");
> originateAction.setContext("from-sip");
> originateAction.setExten("DESTINATIONNUMBERHERE");
> originateAction.setPriority(1);
> originateAction.setTimeout(15000l);
> asteriskServer.originateAsync(originateAction, new
> myCallbackHandler("TESTCALL"));
>
> System.out.println("now idling for a minute to get a
> chance to receive events and states...");
> try {
> Thread.sleep(60000);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
>
> public static void main(String[] args) throws Exception{
> CallTestWithCallbackHandler aCall = new
> CallTestWithCallbackHandler();
> }
>
> @Override
> public void onNewAsteriskChannel(AsteriskChannel channel) {
> System.out.println("new Channel created... data is: "+channel);
>
> }
>
> @Override
> public void onNewMeetMeUser(MeetMeUser user) {
> }
>
> @Override
> public void onNewAgent(AsteriskAgentImpl agent) {
> }
>
> @Override
> public void onNewQueueEntry(AsteriskQueueEntry entry) {
> }
>
> @Override
> public void onManagerEvent(ManagerEvent event) {
> // only print out relevant events here..
> if (event instanceof NewChannelEvent
> || event instanceof ChannelUpdateEvent
> || event instanceof OriginateResponseEvent
> || event instanceof OriginateFailureEvent
> || event instanceof OriginateSuccessEvent
> || event instanceof NewCallerIdEvent
> || event instanceof NewStateEvent
> || event instanceof LinkEvent
> || event instanceof UnlinkEvent
> || event instanceof BridgeEvent
> || event instanceof DialEvent
> || event instanceof HangupEvent)
> System.out.println("got Event: "+event);
>
> }
>
> }
>
> an execution prints out, what happens in detail during a call setup, the
> call itself and the hangup..
> output of callbackhandler is blue, managerevents are red, serverevents
> are violet and important details are *black,bold and underlined*...
> with this trace you can see very well, what happens at which time...
>
> myCallbackHandler for reference TESTCALL just instantiated.
>
> now idling for a minute to get a chance to receive events and states...
> got Event: org.asteriskjava.manager.event.*NewChannelEvent*[dateReceived='Wed
> Mar 06 15:30:02 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*Rsrvd
> *',channelstate='1',calleridname=null,timestamp=null,uniqueid='*
> 1362580137.4260*
> ',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Rsrvd',systemHashcode=1564136253]
> got Event: org.asteriskjava.manager.event.*NewStateEvent*[dateReceived='Wed
> Mar 06 15:30:02 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='Dialing',channelstate='3',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Dialing',systemHashcode=959993440]
> myCallbackHandler for reference TESTCALL receives state: Dialling,
> channelID is: *1362580137.4260*, State is: RSRVD
> new Channel created... data is: AsteriskChannel[id='*1362580137.4260*',name='DAHDI/i1/SOURCENUMBERHERE-24d',callerId='',state='RSRVD',account='null',dateOfCreation=Wed
> Mar 06 15:30:02 CET
> 2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
> got Event: org.asteriskjava.manager.event.*NewStateEvent*[dateReceived='Wed
> Mar 06 15:30:05 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*
> Ringing*',channelstate='5',calleridname=null,timestamp=null,uniqueid='*
> 1362580137.4260*
> ',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Ringing',systemHashcode=591210723]
> got Event: org.asteriskjava.manager.event.*NewStateEvent*[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*Up*
> ',channelstate='6',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Up',systemHashcode=1084010740]
> got Event: org.asteriskjava.manager.event.*OriginateResponseEvent*[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',sequencenumber=null,reason='4',response='*
> Success*',calleridname=null,timestamp=null,uniqueid='*1362580137.4260*
> ',actionid='AJ_ORIGINATE_0',internalactionid='569616903_9',context='from-sip',exten='DESTINATIONNUMBERHERE',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1864729679]
> myCallbackHandler for reference TESTCALL receives state: Success,
> channelID is: *1362580137.4260*, State is: *UP*
> got Event: org.asteriskjava.manager.event.*NewChannelEvent*[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*Rsrvd
> *',channelstate='1',calleridname=null,timestamp=null,uniqueid='*
> 1362580141.4261*
> ',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Rsrvd',systemHashcode=198249052]
> got Event: org.asteriskjava.manager.event.*NewStateEvent*[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='
> *Dialing*',channelstate='3',calleridname=null,timestamp=null,uniqueid='*
> 1362580141.4261*
> ',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Dialing',systemHashcode=1832874625]
> got Event: org.asteriskjava.manager.event.*DialEvent*[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',subevent='Begin',callerid=null,dialstatus=null,sequencenumber=null,
> *destuniqueid='1362580141.4261',srcuniqueid='1362580137.4260'*
> ,destination='DAHDI/i1/DESTINATIONNUMBERHERE-24e',dialstring='g0/DESTINATIONNUMBERHERE',timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1000613778]
> new Channel created... data is: AsteriskChannel[*id='1362580141.4261'*
> ,name='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerId='',state='*RSRVD*',account='null',dateOfCreation=Wed
> Mar 06 15:30:07 CET
> 2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
> got Event: org.asteriskjava.manager.event.*NewStateEvent*[dateReceived='Wed
> Mar 06 15:30:12 CET
> 2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='
> *Ringing*',channelstate='5',calleridname=null,timestamp=null,uniqueid='*
> 1362580141.4261*
> ',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Ringing',systemHashcode=158635208]
> got Event: org.asteriskjava.manager.event.*NewStateEvent*[dateReceived='Wed
> Mar 06 15:30:14 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*Up*
> ',channelstate='6',calleridname=null,timestamp=null,uniqueid='*
> 1362580141.4261*
> ',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Up',systemHashcode=1232704349]
> got Event: org.asteriskjava.manager.event.*BridgeEvent*[dateReceived='Wed
> Mar 06 15:30:14 CET 2013',privilege='call,all',*
> uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*
> ,sequencenumber=null,bridgestate='*Link*
> ',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=45104096]
> got Event: org.asteriskjava.manager.event.*BridgeEvent*[dateReceived='Wed
> Mar 06 15:30:17 CET 2013',privilege='call,all',*
> uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*
> ,sequencenumber=null,bridgestate='*Unlink*
> ',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=277466206]
> got Event: org.asteriskjava.manager.event.*HangupEvent*[dateReceived='Wed
> Mar 06 15:30:17 CET 2013',privilege='call,all',causetxt='Normal
> Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='
> *1362580141.4261*
> ',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',systemHashcode=2110683211]
> got Event: org.asteriskjava.manager.event.*DialEvent*[dateReceived='Wed
> Mar 06 15:30:17 CET
> 2013',privilege='call,all',subevent='End',callerid=null,dialstatus='*
> ANSWER*',sequencenumber=null,destuniqueid=null,srcuniqueid='*
> 1362580137.4260*
> ',destination=null,dialstring=null,timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1501740254]
> got Event: org.asteriskjava.manager.event.*HangupEvent*[dateReceived='Wed
> Mar 06 15:30:17 CET 2013',privilege='call,all',causetxt='Normal
> Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='
> *1362580137.4260*
> ',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=373145787]
>
>
>
> regards,
> yves
>
> Am 06.03.2013 13:23, schrieb Mordechay Kaganer:
>
> B.H.
>
> Hi
>
> There is indeed some problem with OriginateAction events - but it seems
> to be asterisk's problem. When i send OriginateAction (in async mode, but
> this doesn't really matter AFAIK), asterisk immediately create a channel
> and starts to ring while it do generate all related AMI events like
> NewChannelEvent, NewStateEvent on that channel, but until the call
> is established or failed the AMI listener is unable to link between the
> OriginateAction and the new channel. Only OriginateResponseEvent will
> contain both OriginateAction's id and the newly created channel. This means
> that there's no way to get status updates on ongoing originate action like
> see if the channel is ringing or dialing or whatever, even that the same
> app "sees" the new channel and it's status updates.
>
> At least, that's what i have learned from my experience. Maybe somebody
> knows how to workaround this?
>
>
> On Wed, Mar 6, 2013 at 1:38 PM, Yves A. <yv...@gm...> wrote:
>
>> hi,
>>
>> pls. see attached source...
>>
>>
>> package tests;
>>
>>
>> import org.asteriskjava.live.AsteriskChannel;
>> import org.asteriskjava.live.DefaultAsteriskServer;
>> import org.asteriskjava.live.LiveException;
>> import org.asteriskjava.live.OriginateCallback;
>> import org.asteriskjava.manager.ManagerConnection;
>> import org.asteriskjava.manager.action.OriginateAction;
>>
>>
>> public class CallTestWithCallbackHandler {
>>
>> private static ManagerConnection managerConnection;
>>
>> public static void main(String[] args) throws Exception{
>>
>> DefaultAsteriskServer asteriskServer = new
>> DefaultAsteriskServer("SERVER", "USER", "PASSWORD");
>> asteriskServer.getManagerConnection().login();
>>
>>
>> try {
>> OriginateAction originateAction = new OriginateAction();
>> originateAction.setChannel("SIP/177"); //first leg
>> originateAction.setContext("from-internal");
>> originateAction.setExten("08154711"); //second leg
>> originateAction.setPriority(1);
>> originateAction.setTimeout(15000);
>> asteriskServer.originateAsync(originateAction, new
>> myCallbackHandler("177"));
>> System.out.println("now idling for a minute to get a
>> chance to receive events and states...");
>> try {
>> Thread.sleep(60000);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> }
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> }
>> }
>> }
>>
>>
>>
>> package tests;
>>
>> import org.asteriskjava.live.AsteriskChannel;
>> import org.asteriskjava.live.LiveException;
>> import org.asteriskjava.live.OriginateCallback;
>>
>> public class myCallbackHandler implements OriginateCallback{
>>
>>
>> public String reference;
>>
>> public myCallbackHandler(String reference){
>> System.out.println("myCallbackHandler for reference "+reference+"
>> just instantiated.");
>> this.reference = reference;
>> }
>>
>> public void onDialing(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference "+reference+"
>> receives state: Dialling, channelID is: "+ac.getId()+", State is:
>> "+ac.getState());
>>
>> String channelID=ac.getId();
>> }
>>
>> public void onBusy(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference "+reference+"
>> receives state: Busy, channelID is: "+ac.getId()+", State is:
>> "+ac.getState());
>> }
>>
>> public void onFailure(LiveException le)
>> {
>> System.out.println("myCallbackHandler for reference "+reference+"
>> receives state: Failure "+le.getMessage());
>> }
>>
>> public void onNoAnswer(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference "+reference+"
>> receives state: No Answer, channelID is: "+ac.getId()+", State is:
>> "+ac.getState());
>> }
>>
>> public void onSuccess(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference "+reference+"
>> receives state: Success, channelID is: "+ac.getId()+", State is:
>> "+ac.getState());
>> }
>>
>> }
>>
>>
>> regards,
>> yves
>>
>>
>> Am 06.03.2013 04:57, schrieb roko:
>>
>> Hi
>>
>> I use the SendActionCallback, but I'm getting the same response that I
>> get from the blocking function... no new data. So, how can I get the value
>> of the ORIGINATE_STATUS variable ?
>>
>> E.
>>
>> ------------------------------
>> *De:* roko <ro...@ya...> <ro...@ya...>
>> *Para:* "ast...@li..."<ast...@li...>
>> <ast...@li...><ast...@li...>
>> *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M.
>> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value
>> after OriginateAction
>>
>> Hi
>>
>> Thx for your answer. Do you mean instead of blocking using:
>>
>> ManagerResponse<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>
>> sendAction(ManagerAction<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>> long timeout)
>>
>> Should I use this function ?:
>>
>> void sendAction(ManagerAction<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>> SendActionCallback<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html>
>> callback)
>>
>> I see in the docs that I still get a ManagerResponse<http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>.
>> Pls forgive me, I'm very new at this. How can I get the ORIGINATE_STATUS
>> from the ManagerResponse object ? Do you have an example that I could use
>> ? Thx for your help.
>>
>> E.
>>
>> ------------------------------
>> *De:* Yves A. <yv...@gm...> <yv...@gm...>
>> *Para:* ast...@li...
>> *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M.
>> *Asunto:* Re: [Asterisk-java-users] How to get ORIGINATE_STATUS value
>> after OriginateAction
>>
>> Hi,
>>
>> you could use a callback handler. this way you´ll get informed about any
>> state change.
>>
>> yves
>>
>> Am 04.03.2013 04:06, schrieb roko:
>>
>> Hi everyone
>>
>> I'm just starting with asterisk and asterisk-java, so please forgive me
>> if this is a silly question. Here
>> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate)<http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate>I can see that the originate cmd sets the ORIGINATE_STATUS variable before
>> exiting. How can I get this value from asterisk-java ? At this point I'm
>> using the code from the tutorial, like this:
>>
>> OriginateAction originateAction;
>> ManagerResponse originateResponse;
>>
>> originateAction = new OriginateAction();
>> originateAction.setChannel("SIP/John");
>> originateAction.setContext("default");
>> originateAction.setExten("1300");
>> originateAction.setPriority(new Integer(1));
>> originateAction.setTimeout(new Integer(30000));
>>
>> managerConnection.login();
>> originateResponse = managerConnection.sendAction(originateAction, 30000);
>>
>> Thx for your help.
>>
>> E.
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:http://p.sf.net/sfu/appdyn_d2d_feb
>>
>>
>>
>> _______________________________________________
>> Asterisk-java-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li...
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li...
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev
>>
>>
>>
>> _______________________________________________
>> Asterisk-java-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, access the full report.
>> http://p.sf.net/sfu/symantec-dev2dev
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li...
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>
>
> --
> משיח NOW!
> Moshiach is coming very soon, prepare yourself!
> יחי אדוננו מורינו ורבינו מלך המשיח לעולם ועד!
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev
>
>
>
> _______________________________________________
> Asterisk-java-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
--
משיח NOW!
Moshiach is coming very soon, prepare yourself!
יחי אדוננו מורינו ורבינו מלך המשיח לעולם ועד!
|
|
From: Yves A. <yv...@gm...> - 2013-03-12 08:46:36
|
hi,
sorry for the late reply, mail went into SPAM...
it IS possible, even with multiple calls to the same number, to identify
each event and relate it to the originating call..
I've written some day ago a class for this purpose... the trick is to
identify the unique channel-ids for each connected leg.
this way I could e.g. log any event and relate to the call... much
better than the verbose cli output where it is difficult to trace
what happens, if you have high traffic...
basically, this was my approach:
1.) catch all events, store them in a hash <String,Vector> where string
is the unique id, if you catch an event, add the event to the vector
that is stored with the unique id as the key in the hash (if id occurs
first time, create the vector first of course)
2.) originate with callback (not a must) to get the first-leg-unique id
3.) on a bridge event, catch the bridged channel id and you have your
pair of channels...
4.) on hangup, get all related events from your hash, order them by time
and you are done.
5.) do not forget to clear the data from your hash... it might become
full and procude ooM-exceptions, if you do not do so..
thats just a short extract... of course there was a little bit more to
think about... my class could also handle channel-rename events,
masquerades and therefore use of multiple (local too) channels, as they
may come up when you dial multiple targets, do forwards and so on.
regards,
yves
Am 06.03.2013 16:17, schrieb Mordechay Kaganer:
> B.H.
>
> Yves, thanks for the testing and the logs :-). That's exactly what
> i meant. At least in relation to dialing real PSTN numbers, matching
> the call by the dialed phone number will be a bad idea because it's
> not really unique. Theoretically, it's perfectly OK to dial the same
> number several times in parallel, at least if the destination is some
> kind of office PBX or IVR e t.c.
>
> Maybe, to workaround it will be possible to dial to "local" channel,
> answer() the call and then dial out from the dialplan. Then
> OriginateAction will always succeed almost immediately and then
> application will be able to track the actual dial out process by
> tracking the bridged channel. But IMHO it will require a lot of
> resources and not really practical with significant call volumes.
>
> Thanks for the advice, anyway :-)
>
>
>
> On Wed, Mar 6, 2013 at 4:56 PM, Yves A. <yv...@gm...
> <mailto:yv...@gm...>> wrote:
>
> maybe we talk about different things, but if i run my given code,
> i can see status updates via callbackhandler...
> I agree, that there is obviously no way to _immediately_ get the
> channelID via asynchronous dial, but thats
> no problem, because you can pass your own references to the
> callbackhandler constructor. In my example it
> is a simple string, but you could pass any other object there..
> if your listening to ami events only, you could match the value of
> the channel (event.getChannel) against the
> "number" you dialed and can track any state of your call this
> way.... (but i admit... there are nuts and bolts...
> redirecting calls, ringgroups, followme, local channels, queues
> and so on can make track a call quite hard...)
>
> the following example uses callbackhandler plus eventlisteners to
> get all information in realtime:
>
> package tests;
>
>
> import org.asteriskjava.live.AsteriskChannel;
> import org.asteriskjava.live.AsteriskQueueEntry;
> import org.asteriskjava.live.AsteriskServerListener;
> import org.asteriskjava.live.DefaultAsteriskServer;
> import org.asteriskjava.live.MeetMeUser;
> import org.asteriskjava.live.internal.AsteriskAgentImpl;
> import org.asteriskjava.manager.ManagerConnection;
> import org.asteriskjava.manager.ManagerEventListener;
> import org.asteriskjava.manager.action.OriginateAction;
> import org.asteriskjava.manager.event.BridgeEvent;
> import org.asteriskjava.manager.event.ChannelUpdateEvent;
> import org.asteriskjava.manager.event.DialEvent;
> import org.asteriskjava.manager.event.HangupEvent;
> import org.asteriskjava.manager.event.LinkEvent;
> import org.asteriskjava.manager.event.ManagerEvent;
> import org.asteriskjava.manager.event.NewAccountCodeEvent;
> import org.asteriskjava.manager.event.NewCallerIdEvent;
> import org.asteriskjava.manager.event.NewChannelEvent;
> import org.asteriskjava.manager.event.NewStateEvent;
> import org.asteriskjava.manager.event.OriginateFailureEvent;
> import org.asteriskjava.manager.event.OriginateResponseEvent;
> import org.asteriskjava.manager.event.OriginateSuccessEvent;
> import org.asteriskjava.manager.event.UnlinkEvent;
>
>
> public class CallTestWithCallbackHandler implements
> AsteriskServerListener, ManagerEventListener{
>
> private static ManagerConnection managerConnection;
>
> public CallTestWithCallbackHandler() throws Exception{
>
> DefaultAsteriskServer asteriskServer = new
> DefaultAsteriskServer("SERVER", "USERNAME", "PASSWORD");
> asteriskServer.getManagerConnection().login();
> asteriskServer.addAsteriskServerListener(this);
> asteriskServer.getManagerConnection().addEventListener(this);
>
>
>
> try {
> OriginateAction originateAction = new
> OriginateAction();
> originateAction.setChannel("DAHDI/g0/SOURCENUMBERHERE");
> originateAction.setContext("from-sip");
> originateAction.setExten("DESTINATIONNUMBERHERE");
> originateAction.setPriority(1);
> originateAction.setTimeout(15000l);
> asteriskServer.originateAsync(originateAction, new
> myCallbackHandler("TESTCALL"));
>
> System.out.println("now idling for a minute to get
> a chance to receive events and states...");
> try {
> Thread.sleep(60000);
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
> catch (Exception e) {
> System.out.println(e.getMessage());
> }
> }
>
> public static void main(String[] args) throws Exception{
> CallTestWithCallbackHandler aCall = new
> CallTestWithCallbackHandler();
> }
>
> @Override
> public void onNewAsteriskChannel(AsteriskChannel channel) {
> System.out.println("new Channel created... data is:
> "+channel);
>
> }
>
> @Override
> public void onNewMeetMeUser(MeetMeUser user) {
> }
>
> @Override
> public void onNewAgent(AsteriskAgentImpl agent) {
> }
>
> @Override
> public void onNewQueueEntry(AsteriskQueueEntry entry) {
> }
>
> @Override
> public void onManagerEvent(ManagerEvent event) {
> // only print out relevant events here..
> if (event instanceof NewChannelEvent
> || event instanceof ChannelUpdateEvent
> || event instanceof OriginateResponseEvent
> || event instanceof OriginateFailureEvent
> || event instanceof OriginateSuccessEvent
> || event instanceof NewCallerIdEvent
> || event instanceof NewStateEvent
> || event instanceof LinkEvent
> || event instanceof UnlinkEvent
> || event instanceof BridgeEvent
> || event instanceof DialEvent
> || event instanceof HangupEvent)
> System.out.println("got Event: "+event);
>
> }
>
> }
>
> an execution prints out, what happens in detail during a call
> setup, the call itself and the hangup..
> output of callbackhandler is blue, managerevents are red,
> serverevents are violet and important details are _*black,bold and
> underlined*_...
> with this trace you can see very well, what happens at which time...
>
> myCallbackHandler for reference TESTCALL just instantiated.
>
> now idling for a minute to get a chance to receive events and
> states...
> got Event:
> org.asteriskjava.manager.event._*NewChannelEvent*_[dateReceived='Wed
> Mar 06 15:30:02 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Rsrvd*_',channelstate='1',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Rsrvd',systemHashcode=1564136253]
> got Event:
> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
> Mar 06 15:30:02 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='Dialing',channelstate='3',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Dialing',systemHashcode=959993440]
> myCallbackHandler for reference TESTCALL receives state: Dialling,
> channelID is: *_1362580137.4260_*, State is: RSRVD
> new Channel created... data is:
> AsteriskChannel[id='_*1362580137.4260*_',name='DAHDI/i1/SOURCENUMBERHERE-24d',callerId='',state='RSRVD',account='null',dateOfCreation=Wed
> Mar 06 15:30:02 CET
> 2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
> got Event:
> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
> Mar 06 15:30:05 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*_Ringing_*',channelstate='5',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Ringing',systemHashcode=591210723]
> got Event:
> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Up*_',channelstate='6',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Up',systemHashcode=1084010740]
> got Event:
> org.asteriskjava.manager.event._*OriginateResponseEvent*_[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',sequencenumber=null,reason='4',response='_*Success*_',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',actionid='AJ_ORIGINATE_0',internalactionid='569616903_9',context='from-sip',exten='DESTINATIONNUMBERHERE',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1864729679]
> myCallbackHandler for reference TESTCALL receives state: Success,
> channelID is: _*1362580137.4260*_, State is: _*UP*_
> got Event:
> org.asteriskjava.manager.event._*NewChannelEvent*_[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Rsrvd*_',channelstate='1',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Rsrvd',systemHashcode=198249052]
> got Event:
> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
> Mar 06 15:30:07 CET
> 2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='_*Dialing*_',channelstate='3',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Dialing',systemHashcode=1832874625]
> got Event:
> org.asteriskjava.manager.event._*DialEvent*_[dateReceived='Wed Mar
> 06 15:30:07 CET
> 2013',privilege='call,all',subevent='Begin',callerid=null,dialstatus=null,sequencenumber=null,_*destuniqueid='1362580141.4261',srcuniqueid='1362580137.4260'*_,destination='DAHDI/i1/DESTINATIONNUMBERHERE-24e',dialstring='g0/DESTINATIONNUMBERHERE',timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1000613778]
> new Channel created... data is:
> AsteriskChannel[_*id='1362580141.4261'*_,name='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerId='',state='_*RSRVD*_',account='null',dateOfCreation=Wed
> Mar 06 15:30:07 CET
> 2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
> got Event:
> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
> Mar 06 15:30:12 CET
> 2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='_*Ringing*_',channelstate='5',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Ringing',systemHashcode=158635208]
> got Event:
> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
> Mar 06 15:30:14 CET
> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Up*_',channelstate='6',calleridname=null,timestamp=null,uniqueid='*_1362580141.4261_*',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Up',systemHashcode=1232704349]
> got Event:
> org.asteriskjava.manager.event._*BridgeEvent*_[dateReceived='Wed
> Mar 06 15:30:14 CET
> 2013',privilege='call,all',_*uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*_,sequencenumber=null,bridgestate='_*Link*_',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=45104096]
> got Event:
> org.asteriskjava.manager.event._*BridgeEvent*_[dateReceived='Wed
> Mar 06 15:30:17 CET
> 2013',privilege='call,all',_*uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*_,sequencenumber=null,bridgestate='_*Unlink*_',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=277466206]
> got Event:
> org.asteriskjava.manager.event._*HangupEvent*_[dateReceived='Wed
> Mar 06 15:30:17 CET 2013',privilege='call,all',causetxt='Normal
> Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',systemHashcode=2110683211]
> got Event:
> org.asteriskjava.manager.event._*DialEvent*_[dateReceived='Wed Mar
> 06 15:30:17 CET
> 2013',privilege='call,all',subevent='End',callerid=null,dialstatus='*_ANSWER_*',sequencenumber=null,destuniqueid=null,srcuniqueid='*_1362580137.4260_*',destination=null,dialstring=null,timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1501740254]
> got Event:
> org.asteriskjava.manager.event._*HangupEvent*_[dateReceived='Wed
> Mar 06 15:30:17 CET 2013',privilege='call,all',causetxt='Normal
> Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=373145787]
>
>
>
> regards,
> yves
>
> Am 06.03.2013 13:23, schrieb Mordechay Kaganer:
>> B.H.
>>
>> Hi
>>
>> There is indeed some problem with OriginateAction events - but it
>> seems to be asterisk's problem. When i send OriginateAction (in
>> async mode, but this doesn't really matter AFAIK), asterisk
>> immediately create a channel and starts to ring while it do
>> generate all related AMI events like NewChannelEvent,
>> NewStateEvent on that channel, but until the call is established
>> or failed the AMI listener is unable to link between the
>> OriginateAction and the new channel. Only OriginateResponseEvent
>> will contain both OriginateAction's id and the newly created
>> channel. This means that there's no way to get status updates on
>> ongoing originate action like see if the channel is ringing or
>> dialing or whatever, even that the same app "sees" the new
>> channel and it's status updates.
>>
>> At least, that's what i have learned from my experience. Maybe
>> somebody knows how to workaround this?
>>
>>
>> On Wed, Mar 6, 2013 at 1:38 PM, Yves A. <yv...@gm...
>> <mailto:yv...@gm...>> wrote:
>>
>> hi,
>>
>> pls. see attached source...
>>
>>
>> package tests;
>>
>>
>> import org.asteriskjava.live.AsteriskChannel;
>> import org.asteriskjava.live.DefaultAsteriskServer;
>> import org.asteriskjava.live.LiveException;
>> import org.asteriskjava.live.OriginateCallback;
>> import org.asteriskjava.manager.ManagerConnection;
>> import org.asteriskjava.manager.action.OriginateAction;
>>
>>
>> public class CallTestWithCallbackHandler {
>>
>> private static ManagerConnection managerConnection;
>>
>> public static void main(String[] args) throws Exception{
>>
>> DefaultAsteriskServer asteriskServer = new
>> DefaultAsteriskServer("SERVER", "USER", "PASSWORD");
>> asteriskServer.getManagerConnection().login();
>>
>>
>> try {
>> OriginateAction originateAction = new
>> OriginateAction();
>> originateAction.setChannel("SIP/177");//first leg
>> originateAction.setContext("from-internal");
>> originateAction.setExten("08154711"); //second leg
>> originateAction.setPriority(1);
>> originateAction.setTimeout(15000);
>> asteriskServer.originateAsync(originateAction, new
>> myCallbackHandler("177"));
>> System.out.println("now idling for a minute to get a chance
>> to receive events and states...");
>> try {
>> Thread.sleep(60000);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> }
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> }
>> }
>> }
>>
>>
>>
>> package tests;
>>
>> import org.asteriskjava.live.AsteriskChannel;
>> import org.asteriskjava.live.LiveException;
>> import org.asteriskjava.live.OriginateCallback;
>>
>> public class myCallbackHandler implements OriginateCallback{
>>
>>
>> public String reference;
>>
>> public myCallbackHandler(String reference){
>> System.out.println("myCallbackHandler for reference
>> "+reference+" just instantiated.");
>> this.reference = reference;
>> }
>>
>> public void onDialing(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference
>> "+reference+" receives state: Dialling, channelID is:
>> "+ac.getId()+", State is: "+ac.getState());
>>
>> String channelID=ac.getId();
>> }
>>
>> public void onBusy(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference
>> "+reference+" receives state: Busy, channelID is:
>> "+ac.getId()+", State is: "+ac.getState());
>> }
>>
>> public void onFailure(LiveException le)
>> {
>> System.out.println("myCallbackHandler for reference
>> "+reference+" receives state: Failure "+le.getMessage());
>> }
>>
>> public void onNoAnswer(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference
>> "+reference+" receives state: No Answer, channelID is:
>> "+ac.getId()+", State is: "+ac.getState());
>> }
>>
>> public void onSuccess(AsteriskChannel ac)
>> {
>> System.out.println("myCallbackHandler for reference
>> "+reference+" receives state: Success, channelID is:
>> "+ac.getId()+", State is: "+ac.getState());
>> }
>>
>> }
>>
>>
>> regards,
>> yves
>>
>>
>> Am 06.03.2013 04:57, schrieb roko:
>>> Hi
>>>
>>> I use the SendActionCallback, but I'm getting the same
>>> response that I get from the blocking function... no new
>>> data. So, how can I get the value of the ORIGINATE_STATUS
>>> variable ?
>>>
>>> E.
>>>
>>> ------------------------------------------------------------------------
>>> *De:* roko <ro...@ya...> <mailto:ro...@ya...>
>>> *Para:* "ast...@li..."
>>> <mailto:ast...@li...>
>>> <ast...@li...>
>>> <mailto:ast...@li...>
>>> *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M.
>>> *Asunto:* Re: [Asterisk-java-users] How to get
>>> ORIGINATE_STATUS value after OriginateAction
>>>
>>> Hi
>>>
>>> Thx for your answer. Do you mean instead of blocking using:
>>>
>>> ManagerResponse
>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html> sendAction(ManagerAction
>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>>> long timeout)
>>>
>>> Should I use this function ?:
>>>
>>> void sendAction(ManagerAction
>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>>> SendActionCallback
>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html> callback)
>>>
>>> I see in the docs that I still get a ManagerResponse
>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>.
>>> Pls forgive me, I'm very new at this. How can I get the
>>> ORIGINATE_STATUS from the ManagerResponse object ? Do you
>>> have an example that I could use ? Thx for your help.
>>>
>>> E.
>>>
>>> ------------------------------------------------------------------------
>>> *De:* Yves A. <yv...@gm...> <mailto:yv...@gm...>
>>> *Para:* ast...@li...
>>> <mailto:ast...@li...>
>>> *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M.
>>> *Asunto:* Re: [Asterisk-java-users] How to get
>>> ORIGINATE_STATUS value after OriginateAction
>>>
>>> Hi,
>>>
>>> you could use a callback handler. this way you´ll get
>>> informed about any state change.
>>>
>>> yves
>>>
>>> Am 04.03.2013 04:06, schrieb roko:
>>>> Hi everyone
>>>>
>>>> I'm just starting with asterisk and asterisk-java, so
>>>> please forgive me if this is a silly question. Here
>>>> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate)
>>>> <http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate>
>>>> I can see that the originate cmd sets the ORIGINATE_STATUS
>>>> variable before exiting. How can I get this value from
>>>> asterisk-java ? At this point I'm using the code from the
>>>> tutorial, like this:
>>>> OriginateAction originateAction;
>>>> ManagerResponse originateResponse;
>>>>
>>>> originateAction = new OriginateAction();
>>>> originateAction.setChannel("SIP/John");
>>>> originateAction.setContext("default");
>>>> originateAction.setExten("1300");
>>>> originateAction.setPriority(new Integer(1));
>>>> originateAction.setTimeout(new Integer(30000));
>>>>
>>>> managerConnection.login();
>>>> originateResponse = managerConnection.sendAction(originateAction, 30000);
>>>> Thx for your help.
>>>>
>>>> E.
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Everyone hates slow websites. So do we.
>>>> Make your web apps faster with AppDynamics
>>>> Download AppDynamics Lite for free today:
>>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>>
>>>>
>>>> _______________________________________________
>>>> Asterisk-java-users mailing list
>>>> Ast...@li... <mailto:Ast...@li...>
>>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Everyone hates slow websites. So do we.
>>> Make your web apps faster with AppDynamics
>>> Download AppDynamics Lite for free today:
>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> Ast...@li...
>>> <mailto:Ast...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Everyone hates slow websites. So do we.
>>> Make your web apps faster with AppDynamics
>>> Download AppDynamics Lite for free today:
>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> Ast...@li...
>>> <mailto:Ast...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>>> endpoint security space. For insight on selecting the right partner to
>>> tackle endpoint security challenges, access the full report.
>>> http://p.sf.net/sfu/symantec-dev2dev
>>>
>>>
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> Ast...@li... <mailto:Ast...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The
>> Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good
>> choice" in the
>> endpoint security space. For insight on selecting the right
>> partner to
>> tackle endpoint security challenges, access the full report.
>> http://p.sf.net/sfu/symantec-dev2dev
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li...
>> <mailto:Ast...@li...>
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>>
>>
>> --
>> ???? NOW!
>> Moshiach is coming very soon, prepare yourself!
>> ??? ?????? ?????? ?????? ??? ????? ????? ???!
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, access the full report.
>> http://p.sf.net/sfu/symantec-dev2dev
>>
>>
>> _______________________________________________
>> Asterisk-java-users mailing list
>> Ast...@li... <mailto:Ast...@li...>
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The
> Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice"
> in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Asterisk-java-users mailing list
> Ast...@li...
> <mailto:Ast...@li...>
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> --
> ???? NOW!
> Moshiach is coming very soon, prepare yourself!
> ??? ?????? ?????? ?????? ??? ????? ????? ???!
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
>
>
> __...
[truncated message content] |
|
From: Carlos G M. <tr...@hu...> - 2013-03-12 10:18:39
|
Just to add to what Ives says, this topic was covered a couple of times
already, and there are some ideas in the list archives, may be even some
code.
Handling channel renames is a must, if I remember correctly :)
-Carlos
Yves A. @ 12/03/2013 05:45 -0300 dixit:
> hi,
>
> sorry for the late reply, mail went into SPAM...
> it IS possible, even with multiple calls to the same number, to identify
> each event and relate it to the originating call..
> I've written some day ago a class for this purpose... the trick is to
> identify the unique channel-ids for each connected leg.
> this way I could e.g. log any event and relate to the call... much
> better than the verbose cli output where it is difficult to trace
> what happens, if you have high traffic...
>
> basically, this was my approach:
>
> 1.) catch all events, store them in a hash <String,Vector> where string
> is the unique id, if you catch an event, add the event to the vector
> that is stored with the unique id as the key in the hash (if id occurs
> first time, create the vector first of course)
> 2.) originate with callback (not a must) to get the first-leg-unique id
> 3.) on a bridge event, catch the bridged channel id and you have your
> pair of channels...
> 4.) on hangup, get all related events from your hash, order them by time
> and you are done.
> 5.) do not forget to clear the data from your hash... it might become
> full and procude ooM-exceptions, if you do not do so..
>
> thats just a short extract... of course there was a little bit more to
> think about... my class could also handle channel-rename events,
> masquerades and therefore use of multiple (local too) channels, as they
> may come up when you dial multiple targets, do forwards and so on.
>
> regards,
> yves
>
> Am 06.03.2013 16:17, schrieb Mordechay Kaganer:
>> B.H.
>>
>> Yves, thanks for the testing and the logs :-). That's exactly what
>> i meant. At least in relation to dialing real PSTN numbers, matching
>> the call by the dialed phone number will be a bad idea because it's
>> not really unique. Theoretically, it's perfectly OK to dial the same
>> number several times in parallel, at least if the destination is some
>> kind of office PBX or IVR e t.c.
>>
>> Maybe, to workaround it will be possible to dial to "local" channel,
>> answer() the call and then dial out from the dialplan. Then
>> OriginateAction will always succeed almost immediately and then
>> application will be able to track the actual dial out process by
>> tracking the bridged channel. But IMHO it will require a lot of
>> resources and not really practical with significant call volumes.
>>
>> Thanks for the advice, anyway :-)
>>
>>
>>
>> On Wed, Mar 6, 2013 at 4:56 PM, Yves A. <yv...@gm...
>> <mailto:yv...@gm...>> wrote:
>>
>> maybe we talk about different things, but if i run my given code,
>> i can see status updates via callbackhandler...
>> I agree, that there is obviously no way to _immediately_ get the
>> channelID via asynchronous dial, but thats
>> no problem, because you can pass your own references to the
>> callbackhandler constructor. In my example it
>> is a simple string, but you could pass any other object there..
>> if your listening to ami events only, you could match the value of
>> the channel (event.getChannel) against the
>> "number" you dialed and can track any state of your call this
>> way.... (but i admit... there are nuts and bolts...
>> redirecting calls, ringgroups, followme, local channels, queues
>> and so on can make track a call quite hard...)
>>
>> the following example uses callbackhandler plus eventlisteners to
>> get all information in realtime:
>>
>> package tests;
>>
>>
>> import org.asteriskjava.live.AsteriskChannel;
>> import org.asteriskjava.live.AsteriskQueueEntry;
>> import org.asteriskjava.live.AsteriskServerListener;
>> import org.asteriskjava.live.DefaultAsteriskServer;
>> import org.asteriskjava.live.MeetMeUser;
>> import org.asteriskjava.live.internal.AsteriskAgentImpl;
>> import org.asteriskjava.manager.ManagerConnection;
>> import org.asteriskjava.manager.ManagerEventListener;
>> import org.asteriskjava.manager.action.OriginateAction;
>> import org.asteriskjava.manager.event.BridgeEvent;
>> import org.asteriskjava.manager.event.ChannelUpdateEvent;
>> import org.asteriskjava.manager.event.DialEvent;
>> import org.asteriskjava.manager.event.HangupEvent;
>> import org.asteriskjava.manager.event.LinkEvent;
>> import org.asteriskjava.manager.event.ManagerEvent;
>> import org.asteriskjava.manager.event.NewAccountCodeEvent;
>> import org.asteriskjava.manager.event.NewCallerIdEvent;
>> import org.asteriskjava.manager.event.NewChannelEvent;
>> import org.asteriskjava.manager.event.NewStateEvent;
>> import org.asteriskjava.manager.event.OriginateFailureEvent;
>> import org.asteriskjava.manager.event.OriginateResponseEvent;
>> import org.asteriskjava.manager.event.OriginateSuccessEvent;
>> import org.asteriskjava.manager.event.UnlinkEvent;
>>
>>
>> public class CallTestWithCallbackHandler implements
>> AsteriskServerListener, ManagerEventListener{
>>
>> private static ManagerConnection managerConnection;
>>
>> public CallTestWithCallbackHandler() throws Exception{
>>
>> DefaultAsteriskServer asteriskServer = new
>> DefaultAsteriskServer("SERVER", "USERNAME", "PASSWORD");
>> asteriskServer.getManagerConnection().login();
>> asteriskServer.addAsteriskServerListener(this);
>> asteriskServer.getManagerConnection().addEventListener(this);
>>
>>
>>
>> try {
>> OriginateAction originateAction = new
>> OriginateAction();
>> originateAction.setChannel("DAHDI/g0/SOURCENUMBERHERE");
>> originateAction.setContext("from-sip");
>> originateAction.setExten("DESTINATIONNUMBERHERE");
>> originateAction.setPriority(1);
>> originateAction.setTimeout(15000l);
>> asteriskServer.originateAsync(originateAction, new
>> myCallbackHandler("TESTCALL"));
>>
>> System.out.println("now idling for a minute to get
>> a chance to receive events and states...");
>> try {
>> Thread.sleep(60000);
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> }
>> }
>> catch (Exception e) {
>> System.out.println(e.getMessage());
>> }
>> }
>>
>> public static void main(String[] args) throws Exception{
>> CallTestWithCallbackHandler aCall = new
>> CallTestWithCallbackHandler();
>> }
>>
>> @Override
>> public void onNewAsteriskChannel(AsteriskChannel channel) {
>> System.out.println("new Channel created... data is:
>> "+channel);
>>
>> }
>>
>> @Override
>> public void onNewMeetMeUser(MeetMeUser user) {
>> }
>>
>> @Override
>> public void onNewAgent(AsteriskAgentImpl agent) {
>> }
>>
>> @Override
>> public void onNewQueueEntry(AsteriskQueueEntry entry) {
>> }
>>
>> @Override
>> public void onManagerEvent(ManagerEvent event) {
>> // only print out relevant events here..
>> if (event instanceof NewChannelEvent
>> || event instanceof ChannelUpdateEvent
>> || event instanceof OriginateResponseEvent
>> || event instanceof OriginateFailureEvent
>> || event instanceof OriginateSuccessEvent
>> || event instanceof NewCallerIdEvent
>> || event instanceof NewStateEvent
>> || event instanceof LinkEvent
>> || event instanceof UnlinkEvent
>> || event instanceof BridgeEvent
>> || event instanceof DialEvent
>> || event instanceof HangupEvent)
>> System.out.println("got Event: "+event);
>>
>> }
>>
>> }
>>
>> an execution prints out, what happens in detail during a call
>> setup, the call itself and the hangup..
>> output of callbackhandler is blue, managerevents are red,
>> serverevents are violet and important details are _*black,bold and
>> underlined*_...
>> with this trace you can see very well, what happens at which time...
>>
>> myCallbackHandler for reference TESTCALL just instantiated.
>>
>> now idling for a minute to get a chance to receive events and
>> states...
>> got Event:
>> org.asteriskjava.manager.event._*NewChannelEvent*_[dateReceived='Wed
>> Mar 06 15:30:02 CET
>> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Rsrvd*_',channelstate='1',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Rsrvd',systemHashcode=1564136253]
>> got Event:
>> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
>> Mar 06 15:30:02 CET
>> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='Dialing',channelstate='3',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Dialing',systemHashcode=959993440]
>> myCallbackHandler for reference TESTCALL receives state: Dialling,
>> channelID is: *_1362580137.4260_*, State is: RSRVD
>> new Channel created... data is:
>> AsteriskChannel[id='_*1362580137.4260*_',name='DAHDI/i1/SOURCENUMBERHERE-24d',callerId='',state='RSRVD',account='null',dateOfCreation=Wed
>> Mar 06 15:30:02 CET
>> 2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
>> got Event:
>> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
>> Mar 06 15:30:05 CET
>> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='*_Ringing_*',channelstate='5',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Ringing',systemHashcode=591210723]
>> got Event:
>> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
>> Mar 06 15:30:07 CET
>> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Up*_',channelstate='6',calleridname=null,timestamp=null,uniqueid='1362580137.4260',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',channelstatedesc='Up',systemHashcode=1084010740]
>> got Event:
>> org.asteriskjava.manager.event._*OriginateResponseEvent*_[dateReceived='Wed
>> Mar 06 15:30:07 CET
>> 2013',privilege='call,all',sequencenumber=null,reason='4',response='_*Success*_',calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',actionid='AJ_ORIGINATE_0',internalactionid='569616903_9',context='from-sip',exten='DESTINATIONNUMBERHERE',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1864729679]
>> myCallbackHandler for reference TESTCALL receives state: Success,
>> channelID is: _*1362580137.4260*_, State is: _*UP*_
>> got Event:
>> org.asteriskjava.manager.event._*NewChannelEvent*_[dateReceived='Wed
>> Mar 06 15:30:07 CET
>> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Rsrvd*_',channelstate='1',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',context='from-pstn',exten=null,accountcode=null,server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Rsrvd',systemHashcode=198249052]
>> got Event:
>> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
>> Mar 06 15:30:07 CET
>> 2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='_*Dialing*_',channelstate='3',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Dialing',systemHashcode=1832874625]
>> got Event:
>> org.asteriskjava.manager.event._*DialEvent*_[dateReceived='Wed Mar
>> 06 15:30:07 CET
>> 2013',privilege='call,all',subevent='Begin',callerid=null,dialstatus=null,sequencenumber=null,_*destuniqueid='1362580141.4261',srcuniqueid='1362580137.4260'*_,destination='DAHDI/i1/DESTINATIONNUMBERHERE-24e',dialstring='g0/DESTINATIONNUMBERHERE',timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1000613778]
>> new Channel created... data is:
>> AsteriskChannel[_*id='1362580141.4261'*_,name='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerId='',state='_*RSRVD*_',account='null',dateOfCreation=Wed
>> Mar 06 15:30:07 CET
>> 2013,dialedChannel=null,dialingChannel=null,linkedChannel=null]
>> got Event:
>> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
>> Mar 06 15:30:12 CET
>> 2013',privilege='call,all',callerid='DESTINATIONNUMBERHERE',sequencenumber=null,state='_*Ringing*_',channelstate='5',calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum='DESTINATIONNUMBERHERE',channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Ringing',systemHashcode=158635208]
>> got Event:
>> org.asteriskjava.manager.event._*NewStateEvent*_[dateReceived='Wed
>> Mar 06 15:30:14 CET
>> 2013',privilege='call,all',callerid=null,sequencenumber=null,state='_*Up*_',channelstate='6',calleridname=null,timestamp=null,uniqueid='*_1362580141.4261_*',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',channelstatedesc='Up',systemHashcode=1232704349]
>> got Event:
>> org.asteriskjava.manager.event._*BridgeEvent*_[dateReceived='Wed
>> Mar 06 15:30:14 CET
>> 2013',privilege='call,all',_*uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*_,sequencenumber=null,bridgestate='_*Link*_',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=45104096]
>> got Event:
>> org.asteriskjava.manager.event._*BridgeEvent*_[dateReceived='Wed
>> Mar 06 15:30:17 CET
>> 2013',privilege='call,all',_*uniqueid1='1362580137.4260',uniqueid2='1362580141.4261'*_,sequencenumber=null,bridgestate='_*Unlink*_',bridgetype='core',timestamp=null,channel1='DAHDI/i1/SOURCENUMBERHERE-24d',channel2='DAHDI/i1/DESTINATIONNUMBERHERE-24e',callerid1=null,server=null,callerid2=null,systemHashcode=277466206]
>> got Event:
>> org.asteriskjava.manager.event._*HangupEvent*_[dateReceived='Wed
>> Mar 06 15:30:17 CET 2013',privilege='call,all',causetxt='Normal
>> Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='_*1362580141.4261*_',server=null,calleridnum=null,channel='DAHDI/i1/DESTINATIONNUMBERHERE-24e',systemHashcode=2110683211]
>> got Event:
>> org.asteriskjava.manager.event._*DialEvent*_[dateReceived='Wed Mar
>> 06 15:30:17 CET
>> 2013',privilege='call,all',subevent='End',callerid=null,dialstatus='*_ANSWER_*',sequencenumber=null,destuniqueid=null,srcuniqueid='*_1362580137.4260_*',destination=null,dialstring=null,timestamp=null,calleridname=null,uniqueid='1362580137.4260',server=null,src='DAHDI/i1/SOURCENUMBERHERE-24d',calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=1501740254]
>> got Event:
>> org.asteriskjava.manager.event._*HangupEvent*_[dateReceived='Wed
>> Mar 06 15:30:17 CET 2013',privilege='call,all',causetxt='Normal
>> Clearing',callerid=null,cause='16',sequencenumber=null,calleridname=null,timestamp=null,uniqueid='_*1362580137.4260*_',server=null,calleridnum=null,channel='DAHDI/i1/SOURCENUMBERHERE-24d',systemHashcode=373145787]
>>
>>
>>
>> regards,
>> yves
>>
>> Am 06.03.2013 13:23, schrieb Mordechay Kaganer:
>>> B.H.
>>>
>>> Hi
>>>
>>> There is indeed some problem with OriginateAction events - but it
>>> seems to be asterisk's problem. When i send OriginateAction (in
>>> async mode, but this doesn't really matter AFAIK), asterisk
>>> immediately create a channel and starts to ring while it do
>>> generate all related AMI events like NewChannelEvent,
>>> NewStateEvent on that channel, but until the call is established
>>> or failed the AMI listener is unable to link between the
>>> OriginateAction and the new channel. Only OriginateResponseEvent
>>> will contain both OriginateAction's id and the newly created
>>> channel. This means that there's no way to get status updates on
>>> ongoing originate action like see if the channel is ringing or
>>> dialing or whatever, even that the same app "sees" the new
>>> channel and it's status updates.
>>>
>>> At least, that's what i have learned from my experience. Maybe
>>> somebody knows how to workaround this?
>>>
>>>
>>> On Wed, Mar 6, 2013 at 1:38 PM, Yves A. <yv...@gm...
>>> <mailto:yv...@gm...>> wrote:
>>>
>>> hi,
>>>
>>> pls. see attached source...
>>>
>>>
>>> package tests;
>>>
>>>
>>> import org.asteriskjava.live.AsteriskChannel;
>>> import org.asteriskjava.live.DefaultAsteriskServer;
>>> import org.asteriskjava.live.LiveException;
>>> import org.asteriskjava.live.OriginateCallback;
>>> import org.asteriskjava.manager.ManagerConnection;
>>> import org.asteriskjava.manager.action.OriginateAction;
>>>
>>>
>>> public class CallTestWithCallbackHandler {
>>>
>>> private static ManagerConnection managerConnection;
>>>
>>> public static void main(String[] args) throws Exception{
>>>
>>> DefaultAsteriskServer asteriskServer = new
>>> DefaultAsteriskServer("SERVER", "USER", "PASSWORD");
>>> asteriskServer.getManagerConnection().login();
>>>
>>>
>>> try {
>>> OriginateAction originateAction = new
>>> OriginateAction();
>>> originateAction.setChannel("SIP/177");//first leg
>>> originateAction.setContext("from-internal");
>>> originateAction.setExten("08154711"); //second leg
>>> originateAction.setPriority(1);
>>> originateAction.setTimeout(15000);
>>> asteriskServer.originateAsync(originateAction, new
>>> myCallbackHandler("177"));
>>> System.out.println("now idling for a minute to get a chance
>>> to receive events and states...");
>>> try {
>>> Thread.sleep(60000);
>>> }
>>> catch (Exception e) {
>>> System.out.println(e.getMessage());
>>> }
>>> }
>>> catch (Exception e) {
>>> System.out.println(e.getMessage());
>>> }
>>> }
>>> }
>>>
>>>
>>>
>>> package tests;
>>>
>>> import org.asteriskjava.live.AsteriskChannel;
>>> import org.asteriskjava.live.LiveException;
>>> import org.asteriskjava.live.OriginateCallback;
>>>
>>> public class myCallbackHandler implements OriginateCallback{
>>>
>>>
>>> public String reference;
>>>
>>> public myCallbackHandler(String reference){
>>> System.out.println("myCallbackHandler for reference
>>> "+reference+" just instantiated.");
>>> this.reference = reference;
>>> }
>>>
>>> public void onDialing(AsteriskChannel ac)
>>> {
>>> System.out.println("myCallbackHandler for reference
>>> "+reference+" receives state: Dialling, channelID is:
>>> "+ac.getId()+", State is: "+ac.getState());
>>>
>>> String channelID=ac.getId();
>>> }
>>>
>>> public void onBusy(AsteriskChannel ac)
>>> {
>>> System.out.println("myCallbackHandler for reference
>>> "+reference+" receives state: Busy, channelID is:
>>> "+ac.getId()+", State is: "+ac.getState());
>>> }
>>>
>>> public void onFailure(LiveException le)
>>> {
>>> System.out.println("myCallbackHandler for reference
>>> "+reference+" receives state: Failure "+le.getMessage());
>>> }
>>>
>>> public void onNoAnswer(AsteriskChannel ac)
>>> {
>>> System.out.println("myCallbackHandler for reference
>>> "+reference+" receives state: No Answer, channelID is:
>>> "+ac.getId()+", State is: "+ac.getState());
>>> }
>>>
>>> public void onSuccess(AsteriskChannel ac)
>>> {
>>> System.out.println("myCallbackHandler for reference
>>> "+reference+" receives state: Success, channelID is:
>>> "+ac.getId()+", State is: "+ac.getState());
>>> }
>>>
>>> }
>>>
>>>
>>> regards,
>>> yves
>>>
>>>
>>> Am 06.03.2013 04:57, schrieb roko:
>>>> Hi
>>>>
>>>> I use the SendActionCallback, but I'm getting the same
>>>> response that I get from the blocking function... no new
>>>> data. So, how can I get the value of the ORIGINATE_STATUS
>>>> variable ?
>>>>
>>>> E.
>>>>
>>>> ------------------------------------------------------------------------
>>>> *De:* roko <ro...@ya...> <mailto:ro...@ya...>
>>>> *Para:* "ast...@li..."
>>>> <mailto:ast...@li...>
>>>> <ast...@li...>
>>>> <mailto:ast...@li...>
>>>> *Enviado:* Lunes, 4 de marzo, 2013 10:38 A.M.
>>>> *Asunto:* Re: [Asterisk-java-users] How to get
>>>> ORIGINATE_STATUS value after OriginateAction
>>>>
>>>> Hi
>>>>
>>>> Thx for your answer. Do you mean instead of blocking using:
>>>>
>>>> ManagerResponse
>>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html> sendAction(ManagerAction
>>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>>>> long timeout)
>>>>
>>>> Should I use this function ?:
>>>>
>>>> void sendAction(ManagerAction
>>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/ManagerAction.html> action,
>>>> SendActionCallback
>>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/SendActionCallback.html> callback)
>>>>
>>>> I see in the docs that I still get a ManagerResponse
>>>> <http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/response/ManagerResponse.html>.
>>>> Pls forgive me, I'm very new at this. How can I get the
>>>> ORIGINATE_STATUS from the ManagerResponse object ? Do you
>>>> have an example that I could use ? Thx for your help.
>>>>
>>>> E.
>>>>
>>>> ------------------------------------------------------------------------
>>>> *De:* Yves A. <yv...@gm...> <mailto:yv...@gm...>
>>>> *Para:* ast...@li...
>>>> <mailto:ast...@li...>
>>>> *Enviado:* Lunes, 4 de marzo, 2013 2:45 A.M.
>>>> *Asunto:* Re: [Asterisk-java-users] How to get
>>>> ORIGINATE_STATUS value after OriginateAction
>>>>
>>>> Hi,
>>>>
>>>> you could use a callback handler. this way you´ll get
>>>> informed about any state change.
>>>>
>>>> yves
>>>>
>>>> Am 04.03.2013 04:06, schrieb roko:
>>>>> Hi everyone
>>>>>
>>>>> I'm just starting with asterisk and asterisk-java, so
>>>>> please forgive me if this is a silly question. Here
>>>>> (http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate)
>>>>> <http://www.voip-info.org/wiki/view/Asterisk+cmd+Originate>
>>>>> I can see that the originate cmd sets the ORIGINATE_STATUS
>>>>> variable before exiting. How can I get this value from
>>>>> asterisk-java ? At this point I'm using the code from the
>>>>> tutorial, like this:
>>>>> OriginateAction originateAction;
>>>>> ManagerResponse originateResponse;
>>>>>
>>>>> originateAction = new OriginateAction();
>>>>> originateAction.setChannel("SIP/John");
>>>>> originateAction.setContext("default");
>>>>> originateAction.setExten("1300");
>>>>> originateAction.setPriority(new Integer(1));
>>>>> originateAction.setTimeout(new Integer(30000));
>>>>>
>>>>> managerConnection.login();
>>>>> originateResponse = managerConnection.sendAction(originateAction, 30000);
>>>>> Thx for your help.
>>>>>
>>>>> E.
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Everyone hates slow websites. So do we.
>>>>> Make your web apps faster with AppDynamics
>>>>> Download AppDynamics Lite for free today:
>>>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Asterisk-java-users mailing list
>>>>> Ast...@li... <mailto:Ast...@li...>
>>>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Everyone hates slow websites. So do we.
>>>> Make your web apps faster with AppDynamics
>>>> Download AppDynamics Lite for free today:
>>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>> _______________________________________________
>>>> Asterisk-java-users mailing list
>>>> Ast...@li...
>>>> <mailto:Ast...@li...>
>>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Everyone hates slow websites. So do we.
>>>> Make your web apps faster with AppDynamics
>>>> Download AppDynamics Lite for free today:
>>>> http://p.sf.net/sfu/appdyn_d2d_feb
>>>> _______________________________________________
>>>> Asterisk-java-users mailing list
>>>> Ast...@li...
>>>> <mailto:Ast...@li...>
>>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>>>> endpoint security space. For insight on selecting the right partner to
>>>> tackle endpoint security challenges, access the full report.
>>>> http://p.sf.net/sfu/symantec-dev2dev
>>>>
>>>>
>>>> _______________________________________________
>>>> Asterisk-java-users mailing list
>>>> Ast...@li... <mailto:Ast...@li...>
>>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Symantec Endpoint Protection 12 positioned as A LEADER in The
>>> Forrester
>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good
>>> choice" in the
>>> endpoint security space. For insight on selecting the right
>>> partner to
>>> tackle endpoint security challenges, access the full report.
>>> http://p.sf.net/sfu/symantec-dev2dev
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> Ast...@li...
>>> <mailto:Ast...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>
>>>
>>>
>>>
>>> --
>>> משיח NOW!
>>> Moshiach is coming very soon, prepare yourself!
>>> יחי אדוננו מורינו ורבינו מלך המשיח לעולם ועד!
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>>> endpoint security space. For insight on selecting the right partner to
>>> tackle endpoint security challenges, access the full report.
>>> http://p.sf.net/sfu/symantec-dev2dev
>>>
>>>
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> Ast...@li... <mailto:Ast...@li...>
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The
>> Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice"
>> in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, acc...
[truncated message content] |