mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 20:08:17 +00:00
- add a UserEvent action that allows a manager client to "broadcast" an event
to all connected manager clients - update the UserEvent application to use the application argument parsing macros and to allow headers to be specified as pipe delimeted arguments (issue #5324, original patch by outtolunc, committed patch by Corydon) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@29017 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
26
manager.c
26
manager.c
@@ -1631,6 +1631,31 @@ static int process_events(struct mansession *s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char mandescr_userevent[] =
|
||||
"Description: Send an event to manager sessions.\n"
|
||||
"Variables: (Names marked with * are required)\n"
|
||||
" *UserEvent: EventStringToSend\n"
|
||||
" Header1: Content1\n"
|
||||
" HeaderN: ContentN\n";
|
||||
|
||||
static int action_userevent(struct mansession *s, struct message *m)
|
||||
{
|
||||
char *event = astman_get_header(m, "UserEvent");
|
||||
char body[2048] = "";
|
||||
int x, bodylen = 0;
|
||||
for (x = 0; x < m->hdrcount; x++) {
|
||||
if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {
|
||||
ast_copy_string(body + bodylen, m->headers[x], sizeof(body) - bodylen - 3);
|
||||
bodylen += strlen(m->headers[x]);
|
||||
ast_copy_string(body + bodylen, "\r\n", 3);
|
||||
bodylen += 2;
|
||||
}
|
||||
}
|
||||
|
||||
manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, body);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_message(struct mansession *s, struct message *m)
|
||||
{
|
||||
char action[80] = "";
|
||||
@@ -2327,6 +2352,7 @@ int init_manager(void)
|
||||
ast_manager_register2("MailboxStatus", EVENT_FLAG_CALL, action_mailboxstatus, "Check Mailbox", mandescr_mailboxstatus );
|
||||
ast_manager_register2("MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count", mandescr_mailboxcount );
|
||||
ast_manager_register2("ListCommands", 0, action_listcommands, "List available manager commands", mandescr_listcommands);
|
||||
ast_manager_register2("UserEvent", EVENT_FLAG_USER, action_userevent, "Send an arbitrary event", mandescr_userevent);
|
||||
ast_manager_register2("WaitEvent", 0, action_waitevent, "Wait for an event to occur", mandescr_waitevent);
|
||||
|
||||
ast_cli_register(&show_mancmd_cli);
|
||||
|
||||
Reference in New Issue
Block a user