mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-03 04:16:43 +00:00
Add vtable and methods for to_json and to_ami for Stasis messages
When a Stasis message type is defined in a loadable module, handling those messages for AMI and res_stasis events can be cumbersome. This patch adds a vtable to stasis_message_type, with to_ami and to_json virtual functions. These allow messages to be handled abstractly without putting module-specific code in core. As an example, the VarSet AMI event was refactored to use the to_ami virtual function. (closes issue ASTERISK-21817) Review: https://reviewboard.asterisk.org/r/2579/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391403 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -35,7 +35,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/channel.h"
|
||||
|
||||
/*! \brief Message type for parked calls */
|
||||
static struct stasis_message_type *parked_call_type;
|
||||
STASIS_MESSAGE_TYPE_DEFN(ast_parked_call_type);
|
||||
|
||||
/*! \brief Topic for parking lots */
|
||||
static struct stasis_topic *parking_topic;
|
||||
@@ -48,15 +48,14 @@ static ast_bridge_channel_park_fn ast_bridge_channel_park_func = NULL;
|
||||
|
||||
void ast_parking_stasis_init(void)
|
||||
{
|
||||
parked_call_type = stasis_message_type_create("ast_parked_call");
|
||||
STASIS_MESSAGE_TYPE_INIT(ast_parked_call_type);
|
||||
parking_topic = stasis_topic_create("ast_parking");
|
||||
}
|
||||
|
||||
void ast_parking_stasis_disable(void)
|
||||
{
|
||||
ao2_cleanup(parked_call_type);
|
||||
STASIS_MESSAGE_TYPE_CLEANUP(ast_parked_call_type);
|
||||
ao2_cleanup(parking_topic);
|
||||
parked_call_type = NULL;
|
||||
parking_topic = NULL;
|
||||
}
|
||||
|
||||
@@ -65,11 +64,6 @@ struct stasis_topic *ast_parking_topic(void)
|
||||
return parking_topic;
|
||||
}
|
||||
|
||||
struct stasis_message_type *ast_parked_call_type(void)
|
||||
{
|
||||
return parked_call_type;
|
||||
}
|
||||
|
||||
/*! \brief Destructor for parked_call_payload objects */
|
||||
static void parked_call_payload_destructor(void *obj)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user