Re: [Asterisk-java-users] Execute Action after connect or reconnect
Brought to you by:
srt
From: Henrik B. <hen...@fr...> - 2007-09-06 10:18:02
|
Thank you both for the fast answers. The solution with the ManagerEventListenerProxy does it for me. Gretings Henrik Am Mittwoch, den 05.09.2007, 22:34 +0200 schrieb Stefan Reuter: > Hi, > > you seem to be mixing the live API and the manager API. While this is > generally possible I think it would be better to just stick with the > live API. You are adding a callback to the ConnectEvent, so maybe the > best solution would be to provide a way to register a few more callbacks > like for connect and disconnect in the live API. > > The problem in this case is that a ManagerAction is send from the event > dispatching thread which is not allowed. Generally the live API handles > this problem by using a ManagerEventListenerProxy but by registering > your own listener with the underlying connection you prevent this from > working correctly. > So what you have to do is to decouple receiving the event and sending > the action on your own. One solution is starting a new Thread as > proposed by Martin. Another solution is to use ManagerEventListenerProxy > for your own listener, too. > This might look like this: > > Instead of > > managerConnection.addEventListener( > new ConnectEventListener(asteriskserver)); > > use > > managerConnection.addEventListener(new ManagerEventListenerProxy( > new ConnectEventListener(asteriskserver))); > |