Thread: [Asterisk-java-users] AsteriskManager
Brought to you by:
srt
From: Alex M. <al...@go...> - 2005-03-07 22:56:49
|
Is there any way to get a concrete implementation of AsteriskManager currently (preferably that uses a pre-existing ManagerConnection for connection information)? What I need to do is get a list of channels and map them to my list of Employee objects so that I can add channel event listeners and have each Employee be self-updating rather than monitoring the ManagerConnection for events that relate to a particular user. Is this possible or will it be possible at some point? --=20 Alex Malinovich Golden Technologies, Inc. (219) 462-7200 x 216 http://www.golden-tech.com |
From: Chris H. <ch...@as...> - 2005-03-15 16:01:54
|
I'm currently working with an older version of Asterisk Java (plan on updating soon but I don't have time for regression test). I have a need for a user defined event but the UserEvent class was not included in the version I was working with. I pull the user event class from the latest cvs and added it. Created my own user event public class UserEventASGHold extends UserEvent { private String callerId; public UserEventASGHold(Object source) { super(source); } public String getCallerId() { return callerId; } public void setCallerId(String callerId) { this.callerId = callerId; } } I call the event via: exten => _0262,10,UserEvent(ASGHold|callerId: ${CALLERIDNUM}) Now I get the warning: WARNING: No event class registered for event type 'usereventasghold', attributes: {callerid=0262, uniqueid=1110900347.498, event=UserEventASGHold, channel=Zap/38-1} How do I register the event? Is this because I'm using a old version of the core code? Thanks, Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.7.2 - Release Date: 3/11/2005 |
From: Stefan R. <sr...@re...> - 2005-03-15 16:25:12
|
On Tue, 2005-03-15 at 10:01 -0600, Chris Howard wrote: > I'm currently working with an older version of Asterisk Java (plan on=20 > updating soon but I don't have time for regression test). I was mainly working on the FastAGI implementation for the last time, so it "shouldn't" break your Manager API stuff. > Created my own user event > public class UserEventASGHold extends UserEvent Your class must be named ASGHoldEvent just the name of the event you will send with the appendix Event. > WARNING: No event class registered for event type 'usereventasghold',=20 > attributes: {callerid=3D0262, uniqueid=3D1110900347.498, event=3DUserEven= tASGHold,=20 > channel=3DZap/38-1} >=20 > How do I register the event? Is this because I'm using a old version of = the=20 > core code? The newer code base includes a method called registerUserEventClass(Class userEventClass) in the ManagerConnection interface so you would just call managerConnection.registerUserEventClass(ASGHoldEvent.class); If you are unable to upgrade right now and don't mind to change Asterisk-java's internal code you can also add your event to the EventBuilder (this is either net.sf.asterisk.manager.EventBuilder or in newer versions net.sf.asterisk.manager.impl.EventBuilderImpl). There is a private method called registerBuiltinEventClasses() where you can add a registerEventClass(ASGHoldEvent.class); Hope that helps =3DStefan |
From: Stefan R. <sr...@re...> - 2005-03-15 16:48:53
|
> > Created my own user event > > public class UserEventASGHold extends UserEvent >=20 > Your class must be named ASGHoldEvent just the name of the event you > will send with the appendix Event. I just had a look at the asterisk sources to verify that and indeed asterisk prefixes user events with UserEvent. So for now your class should be named UserEventASGHoldEvent - which really sucks. |
From: Stefan R. <sr...@re...> - 2005-03-15 18:32:55
|
On Tue, 2005-03-15 at 11:16 -0600, Chris Howard wrote: > Thanks for your help. I named the class UserEventASGHold and all is=20 > working well. ok. i just had a look at my sources to verify whats going on there :) if the class name ends with "event" (ignoring case) that part is stripped of, if not it is takes the full class name. I added support for user events to latest cvs so if your event extends UserEvent and does not start with "userevent" that string is prepended. so you can name your class ASGHold, ASGHoldEvent, UserEventASGHold or even UserEventASGHoldEvent with latest CVS. I would prefer ASGHoldEvent for a uniform naming schema. > It looks like there are alot of changes is the connection classes. When = I=20 > decide to upgrade to the latest codebase can I expect a speed increase :)= =20 Speed has not yet been optimized. I think the biggest "problem" is currently that the ManagerEventHandlers are called within the same thread as the events are received. So if you do a lot of processing in your handleEvent() methods that will block any other events from being received and (if you registered more than one EventHandler) other EventHandlers from being called timely. There is no easy solution to this because events must be dispatched in the right order. One possible solution is to use a separate Thread for each registered EventHandler. Do you encounter speed problems right now? Do you use multiple EventHandlers? > Also I noticed that NewExtenEvent are very chatty. Would it be faster to= =20 > not register that event if I'm not using it? Yes that might improve speed but if you check for the events you are interested in early in the handleEvent() method and return fast if not interested handling these additional events should not be much of an issue. Note that not registering events received from Asterisk will fill your logs with warnings about that. For the 0.1 release i plan to add an=20 addEventHandler(ManagerEventHandler eventHandler, ManagerEventFilter filer) method to the ManagerConnection so you can indicate which events you are interested in and Asterisk-java will not bother you with the irrelevant ones. =3DStefan |