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:
David M. Lee
2013-06-11 15:46:35 +00:00
parent 2053fc3159
commit dbdb2b1b3a
8 changed files with 430 additions and 119 deletions

View File

@@ -71,7 +71,7 @@ AST_TEST_DEFINE(channel_blob_create)
break;
}
type = stasis_message_type_create("test-type");
type = stasis_message_type_create("test-type", NULL);
chan = ast_channel_alloc(0, AST_STATE_DOWN, "100", "Alice", "100", "100", "default", NULL, 0, "TEST/Alice");
json = ast_json_pack("{s: s}",
"foo", "bar");
@@ -123,7 +123,7 @@ AST_TEST_DEFINE(null_blob)
break;
}
type = stasis_message_type_create("test-type");
type = stasis_message_type_create("test-type", NULL);
chan = ast_channel_alloc(0, AST_STATE_DOWN, "100", "Alice", "100", "100", "default", NULL, 0, "TEST/Alice");
json = ast_json_pack("{s: s}",
"foo", "bar");