Asterisk-Java

org.asteriskjava.manager.event
Class AsyncAgiEvent

java.lang.Object
  extended by java.util.EventObject
      extended by org.asteriskjava.manager.event.ManagerEvent
          extended by org.asteriskjava.manager.event.ResponseEvent
              extended by org.asteriskjava.manager.event.AsyncAgiEvent
All Implemented Interfaces:
java.io.Serializable

public class AsyncAgiEvent
extends ResponseEvent

The following sub events are reported:

It is implemented in res/res_agi.c.

Available since Asterisk 1.6

Since:
1.0.0
Version:
$Id: AsyncAgiEvent.java 1169 2008-09-18 07:06:52Z srt $
Author:
srt
See Also:
AgiAction, Serialized Form

Field Summary
static java.lang.String SUB_EVENT_END
           
static java.lang.String SUB_EVENT_EXEC
           
static java.lang.String SUB_EVENT_START
           
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
AsyncAgiEvent(java.lang.Object source)
          Creates a new AsyncAgiEvent.
 
Method Summary
 java.util.List<java.lang.String> decodeEnv()
          Decodes the AGI environment and returns a list of lines.
 java.util.List<java.lang.String> decodeResult()
          Decodes the result.
 java.lang.String getChannel()
          Returns the name of the channel this event occurred on.
 java.lang.String getCommandId()
          Returns the command id of the corresponding AgiAction.
 java.lang.String getEnv()
          Returns the raw AGI environment similar to the AGI request for FastAGI.
 java.lang.String getResult()
          Returns the raw result of a command execution in response to the corresponding AgiAction.
 java.lang.String getSubEvent()
          Returns the sub event type.
 boolean isEnd()
          Checks is this an end sub event.
 boolean isExec()
          Checks is this an exec sub event.
 boolean isStart()
          Checks is this a start sub event.
protected  boolean isSubEvent(java.lang.String subEvent)
           
 void setChannel(java.lang.String channel)
          Sets the name of the channel this event occurred on.
 void setCommandId(java.lang.String commandId)
          Sets the command id.
 void setEnv(java.lang.String env)
          Sets the AGI environment.
 void setResult(java.lang.String result)
          Sets the raw result.
 void setSubEvent(java.lang.String subEvent)
          Sets the sub event type.
 
Methods inherited from class org.asteriskjava.manager.event.ResponseEvent
getActionId, getInternalActionId, setActionId, setInternalActionId
 
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

SUB_EVENT_START

public static final java.lang.String SUB_EVENT_START
See Also:
Constant Field Values

SUB_EVENT_EXEC

public static final java.lang.String SUB_EVENT_EXEC
See Also:
Constant Field Values

SUB_EVENT_END

public static final java.lang.String SUB_EVENT_END
See Also:
Constant Field Values
Constructor Detail

AsyncAgiEvent

public AsyncAgiEvent(java.lang.Object source)
Creates a new AsyncAgiEvent.

Parameters:
source -
Method Detail

getChannel

public java.lang.String getChannel()
Returns the name of the channel this event occurred on.

Returns:
the name of the channel this event occurred on.

setChannel

public void setChannel(java.lang.String channel)
Sets the name of the channel this event occurred on.

Parameters:
channel - the name of the channel this event occurred on.

getSubEvent

public java.lang.String getSubEvent()
Returns the sub event type. This is either "Start", "Exec" or "End".

Returns:
the sub event type.

setSubEvent

public void setSubEvent(java.lang.String subEvent)
Sets the sub event type.

Parameters:
subEvent - the sub event type.

getCommandId

public java.lang.String getCommandId()
Returns the command id of the corresponding AgiAction.

This property is only available for the "Exec" sub event.

Returns:
the command id.
See Also:
AgiAction.setCommandId(String)

setCommandId

public void setCommandId(java.lang.String commandId)
Sets the command id.

Parameters:
commandId - the command id.

getResult

public java.lang.String getResult()
Returns the raw result of a command execution in response to the corresponding AgiAction.

This property is only available for the "Exec" sub event.

The result is URL encoded and ends with a newline ("\n").

Example:

 200%20result%3d0
 

Returns:
the URL encoded result.

decodeResult

public java.util.List<java.lang.String> decodeResult()
Decodes the result.

Returns:
the decoded result.

setResult

public void setResult(java.lang.String result)
Sets the raw result.

Parameters:
result - the URL encoded result.

getEnv

public java.lang.String getEnv()
Returns the raw AGI environment similar to the AGI request for FastAGI.

This property is only available for the "Start" sub event.

The environment is passed in multiple lines (separated by "\n"). Each line is URL encoded and contains a key and a value. The environment ends with two newline characters ("\n\n").

Example:

 ...
 agi_channel%3a%20IAX2%2fpbx0-1
 agi_language%3a%20de
 agi_type%3a%20IAX2
 agi_uniqueid%3a%201201838738.19
 agi_version%3a%201.6.0-beta1
 ...
 

Returns:
the URL encoded AGI environment.

decodeEnv

public java.util.List<java.lang.String> decodeEnv()
Decodes the AGI environment and returns a list of lines.

Returns:
The decoded AGI environment or an empty list if the environment is not available (that is if getEnv() returns null).
See Also:
getEnv()

setEnv

public void setEnv(java.lang.String env)
Sets the AGI environment.

Parameters:
env - the URL encoded AGI environment.

isStart

public boolean isStart()
Checks is this a start sub event.

Returns:
true if this is a "Start" sub event, false otherwise.

isExec

public boolean isExec()
Checks is this an exec sub event.

Returns:
true if this is an "Exec" sub event, false otherwise.

isEnd

public boolean isEnd()
Checks is this an end sub event.

Returns:
true if this is an "End" sub event, false otherwise.

isSubEvent

protected boolean isSubEvent(java.lang.String subEvent)

Asterisk-Java

Copyright © 2004-2009 Stefan Reuter. All Rights Reserved.