Re: [Asterisk-java-devel] Reset dtmfReceived
Brought to you by:
srt
|
From: Hoai-Anh Ngo-Vi <ho...@gm...> - 2012-06-05 13:24:22
|
Answer to myself,
Using reflection has worked out. But this seems to me a bit dirty. Is
there any more asterisk-java native way?
+++++
@Override
public void propertyChange(PropertyChangeEvent arg0) {
AsteriskChannel asteriskChannel = (AsteriskChannel)
arg0.getSource();
String chanId = asteriskChannel.getId();
logger.info(chanId+"::"+arg0.getPropertyName()+"::"+arg0.getOldValue());
logger.info(chanId+"::"+arg0.getPropertyName()+"::"+arg0.getNewValue());
// workaround to reset invisible field by default
try {
String fieldName = arg0.getPropertyName();
if(fieldName.startsWith("dtmf")) {
Class<?> c = asteriskChannel.getClass();
java.lang.reflect.Field field =
c.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(asteriskChannel, null);
}
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
+++++
Am 05.06.12 15:16, schrieb Hoai-Anh Ngo-Vi:
> Dear developers,
>
> I add a PropertyChangeListener to AsteriskChannel. In method
> propertyChange() I read the propertiy dtmfReceived. When a single digit,
> let's say '#' is pressed several times the method is called only one
> time. But I want the method to be called everytime so I came to the idea
> of reseting dimfReceived to null. But due to the visibility of
> AsteriskChannelImpl this is not possible. Is there any way to do that? I
> do not want to modify the original Code?
>
> Thank you for your supports
>
--
Ngô Vi Hoài Anh
Biedenkopfer Weg 13
60489 Frankfurt am Main
069 74 22 36 63
0172 53 97 0 82
|