|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.EventObject
org.asteriskjava.manager.event.ManagerEvent
org.asteriskjava.manager.event.DtmfEvent
public class DtmfEvent
A DtmfEvent is triggered each time a DTMF digit is sent or received on a channel.
To support variable-length DTMF Asterisk (since 1.4.0) interally uses two different frames
for DTMF releated events (AST_FRAME_DTMF_BEGIN
and AST_FRAME_DTMF_END
).
Before 1.4.0 Asterisk only used one frame (AST_FRAME_DTMF
) which is now an alias for
AST_FRAME_DTMF_END
.
Many other systems and devices (like mobile phone providers) do not support variable-length DTMF.
In these cases you will only see AST_FRAME_DTMF_END
frames in Asterisk.
When building DTMF aware applications you should not rely on AST_FRAME_DTMF_BEGIN
.
Generally it is safe to just ignore them and only react on AST_FRAME_DTMF_END
frames.
To check whether an DtmfEvent represents an AST_FRAME_DTMF_BEGIN
or
AST_FRAME_DTMF_END
frame use the isBegin()
and isEnd()
methods.
It is implemented in main/channel.c
.
Available since Asterisk 1.6
Field Summary | |
---|---|
static java.lang.String |
DIRECTION_RECEIVED
|
static java.lang.String |
DIRECTION_SENT
|
Fields inherited from class java.util.EventObject |
---|
source |
Constructor Summary | |
---|---|
DtmfEvent(java.lang.Object source)
Creates a new DtmfEvent. |
Method Summary | |
---|---|
java.lang.String |
getChannel()
Returns the name of the channel the DTMF digit was sent or received on. |
java.lang.String |
getDigit()
Returns the DTMF digit that was sent or received. |
java.lang.String |
getDirection()
Returns whether the DTMF digit was sent or received. |
java.lang.String |
getUniqueId()
Returns the unique id of the the channel the DTMF digit was sent or received on. |
java.lang.Boolean |
isBegin()
Returns whether this event represents an AST_FRAME_DTMF_BEGIN frame. |
boolean |
isEnd()
Returns whether this event represents an AST_FRAME_DTMF_END frame. |
boolean |
isReceived()
Returns whether the DTMF digit was received by Asterisk (sent from the device to Asterisk). |
boolean |
isSent()
Returns whether the DTMF digit was sent from Asterisk to the device. |
void |
setBegin(java.lang.Boolean begin)
Sets whether this event represents an AST_FRAME_DTMF_BEGIN frame. |
void |
setChannel(java.lang.String channel)
Sets the name of the channel. |
void |
setDigit(java.lang.String digit)
Sets the DTMF digit that was sent or received. |
void |
setDirection(java.lang.String direction)
Sets whether the DTMF digit was sent or received. |
void |
setEnd(java.lang.Boolean end)
Sets whether this event represents an AST_FRAME_DTMF_END frame. |
void |
setUniqueId(java.lang.String uniqueId)
Sets the unique id of the the channel. |
Methods inherited from class org.asteriskjava.manager.event.ManagerEvent |
---|
appendPropertyIfNotNull, getDateReceived, getFile, getFunc, getLine, getPrivilege, getSequenceNumber, getServer, getTimestamp, setDateReceived, setFile, setFunc, setLine, setPrivilege, setSequenceNumber, setServer, setTimestamp, toString |
Methods inherited from class java.util.EventObject |
---|
getSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DIRECTION_RECEIVED
public static final java.lang.String DIRECTION_SENT
Constructor Detail |
---|
public DtmfEvent(java.lang.Object source)
source
- Method Detail |
---|
public java.lang.String getChannel()
public void setChannel(java.lang.String channel)
channel
- the channel name.public java.lang.String getUniqueId()
public void setUniqueId(java.lang.String uniqueId)
uniqueId
- the unique id of the the channel.public java.lang.String getDigit()
public void setDigit(java.lang.String digit)
digit
- the DTMF digit that was sent or received.public java.lang.String getDirection()
Possible values are:
DIRECTION_RECEIVED
,
DIRECTION_SENT
public void setDirection(java.lang.String direction)
direction
- "Received" or "Sent".public java.lang.Boolean isBegin()
AST_FRAME_DTMF_BEGIN
frame.Gerally your application will want to ignore begin events. You will only need them if you want to make use of the duration a DTMF key was pressed.
Note that there will be DTMF end events without a corresponding begin event as not all systems (including Asterisk prior to 1.4.0) support variable-length DTMF.
true
if this is a DTMF begin event (key pressed),
false
otherwise.public void setBegin(java.lang.Boolean begin)
AST_FRAME_DTMF_BEGIN
frame.
begin
- true
if this is a DTMF begin event (key pressed),
false
otherwise.public boolean isEnd()
AST_FRAME_DTMF_END
frame.DTMF information received from systems that do not support variable-length DTMF you will only see DTMF end events.
true
if this is a DTMF end event (key released),
false
otherwise.public void setEnd(java.lang.Boolean end)
AST_FRAME_DTMF_END
frame.
end
- true
if this is a DTMF end event (key released),
false
otherwise.public boolean isReceived()
true
if the DTMF digit was received by Asterisk,
false
otherwise.getDirection()
public boolean isSent()
true
if the DTMF digit was sent from Asterisk to the device,
false
otherwise.getDirection()
|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |