Thread: [Asterisk-java-devel] Reset dtmfReceived
Brought to you by:
srt
|
From: Hoai-Anh Ngo-Vi <ho...@gm...> - 2012-06-05 13:16:59
|
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 |
|
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
|
|
From: Timothy R. <tim...@gm...> - 2012-06-05 14:20:23
|
I'm not a project contributor. But I think it makes sense that
asterisk-java would invoke the listener for each distinct press. If it
doesn't, wouldn't a better approach be to write a patch for it instead
of using reflection?
On Jun 5, 2012, at 9:24 AM, Hoai-Anh Ngo-Vi <ho...@gm...> wrote:
> 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
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Asterisk-java-devel mailing list
> Ast...@li...
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel
|