Re: [Asterisk-java-users] Execute Action after connect or reconnect
Brought to you by:
srt
From: Stefan R. <ste...@re...> - 2007-09-05 20:33:50
|
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))); =3DStefan |