Summary:ASTERISK-20880: Add channel caching to event subsystem
Reporter:Matt Jordan (mjordan)Labels:Asterisk12
Date Opened:2013-01-03 20:57:34.000-0600Date Closed:2013-02-15 10:30:18.000-0600
Versions:Frequency of
Description:Elements built on top of Stasis-Core will need to subscribe for changes in the channel state and be able to query for a channel's current state. While Stasis-Core may eventually be a separate module/subsystem, for now it makes sense to build the functionality on top of the existing event pub/sub system.

There are a couple of 'requirements' that a solution should meet:
# {{ast_channel}} objects should not be passed directly. Events being raised should not affect the lifetime of the channel object and should not provide direct access to the {{ast_channel}} object, but should instead pass a copy of the necessary information. This helps keep event consumers thread-safe.
# The channel information passed by the event subsystem does not have to be all information contained in a channel, but should carry the name, unique ID, state, and other information likely to change on a channel.
# Alternatively, a key/value pair mechanism containing the updated parameters of the channel can be passed (using either {{ast_variable}} or typed tuples, as prototyped on https://reviewboard.asterisk.org/r/2248/

As an initial candidate of consuming this information, AMI should be refactored to subscribe for channel state updates and send the event based on this information. The existing {{Newstate}} event should be refactored into manager.c and built on top of this information.
Comments:By: Kinsey Moore (kmoore) 2013-01-11 14:07:18.482-0600

The bare minimum information required for the Newstate event:
Channel Name
Unique ID
Channel State
Caller ID
Connected Line Info

Other information that is likely to change:
Music Class
Account Code
Parking Lot
User Field
AMA Flags
Hangup Source
Tone Zone
Named Call Group
Named Pickup Group
Bridged Channel Name
Call Forward
Linked ID
Redirecting Info

The majority of this information must be represented as strings, but some like AMA Flags, Channel State, and Priority are integers.

By: Kinsey Moore (kmoore) 2013-02-06 09:17:15.349-0600

The latest developments on this can be tracked in the team branch:

Currently, the Newchannel, Newstate, and Hangup events have been refactored and relocated to manager.c and the event system has had some overhaul related to providing a blob with constructor, comparator, and destructor to allow usage of data blobs requiring these functions such as structs with stringfields.  In its current state, it passes bridging tests which use these events extensively.