Asterisk - The Open Source Telephony Project  18.5.0
messaging.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2014, Digium, Inc.
5  *
6  * Matt Jordan <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 #ifndef _ASTERISK_RES_STASIS_MESSAGING_H
20 #define _ASTERISK_RES_STASIS_MESSAGING_H
21 
22 /*!
23  * \file
24  *
25  * \brief Stasis out-of-call text message support
26  *
27  * \author Matt Jordan <[email protected]>
28  * \since 12.4.0
29  */
30 
31 /*!
32  * \brief Callback handler for when a message is received from the core
33  *
34  * \param endpoint_id The ID of the endpoint that we received the message from
35  * \param json_msg JSON representation of the text message
36  * \param pvt ao2 ref counted pvt passed during registration
37  *
38  * \retval 0 the message was handled
39  * \retval non-zero the message was not handled
40  */
41 typedef int (* message_received_cb)(const char *endpoint_id, struct ast_json *json_msg, void *pvt);
42 
43 /*!
44  * \brief Subscribe for messages from a particular endpoint
45  *
46  * \param app_name Name of the stasis application to unsubscribe from messaging
47  * \param endpoint_id The ID of the endpoint we no longer care about
48  *
49  * \retval 0 success
50  * \retval -1 error
51  */
52 void messaging_app_unsubscribe_endpoint(const char *app_name, const char *endpoint_id);
53 
54 /*!
55  * \brief Subscribe an application to an endpoint for messages
56  *
57  * \param app_name The name of the \ref stasis application to subscribe to \c endpoint
58  * \param endpoint The endpoint object to subscribe to
59  * \param message_received_cb The callback to call when a message is received
60  * \param pvt An ao2 ref counted object that will be passed to the callback.
61  *
62  * \retval 0 subscription was successful
63  * \retval -1 subscription failed
64  */
65 int messaging_app_subscribe_endpoint(const char *app_name, struct ast_endpoint *endpoint, message_received_cb callback, void *pvt);
66 
67 /*!
68  * \brief Tidy up the messaging layer
69  *
70  * \retval 0 success
71  * \retval -1 failure
72  */
73 int messaging_cleanup(void);
74 
75 /*!
76  * \brief Initialize the messaging layer
77  *
78  * \retval 0 success
79  * \retval -1 failure
80  */
81 int messaging_init(void);
82 
83 #endif /* #define _ASTERISK_RES_STASIS_MESSAGING_H */
int messaging_init(void)
Initialize the messaging layer.
Definition: messaging.c:539
int messaging_cleanup(void)
Tidy up the messaging layer.
Definition: messaging.c:529
int(* message_received_cb)(const char *endpoint_id, struct ast_json *json_msg, void *pvt)
Callback handler for when a message is received from the core.
Definition: messaging.h:41
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463
int messaging_app_subscribe_endpoint(const char *app_name, struct ast_endpoint *endpoint, message_received_cb callback, void *pvt)
Subscribe an application to an endpoint for messages.
Definition: messaging.c:493
Abstract JSON element (object, array, string, int, ...).
void messaging_app_unsubscribe_endpoint(const char *app_name, const char *endpoint_id)
Subscribe for messages from a particular endpoint.
Definition: messaging.c:423