2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2013, Digium, Inc.
6 * David M. Lee, II <dlee@digium.com>
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.
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.
19 #ifndef _ASTERISK_RES_STASIS_APP_H
20 #define _ASTERISK_RES_STASIS_APP_H
24 * \brief Internal API for the Stasis application controller.
26 * \author David M. Lee, II <dlee@digium.com>
30 #include "asterisk/channel.h"
31 #include "asterisk/stasis.h"
32 #include "asterisk/stasis_app.h"
35 * \brief Opaque pointer to \c res_stasis app structure.
40 * \brief Create a res_stasis application.
42 * \param name Name of the application.
43 * \param handler Callback for messages sent to the application.
44 * \param data Data pointer provided to the callback.
45 * \return New \c res_stasis application.
46 * \return \c NULL on error.
48 struct app *app_create(const char *name, stasis_app_cb handler, void *data);
51 * \brief Update the handler and data for a \c res_stasis application.
53 * \param app Application to update.
54 * \param handler New application callback.
55 * \param data New data pointer for the callback.
57 void app_update(struct app *app, stasis_app_cb handler, void *data);
60 * \brief Return an application's name.
62 * \param app Application.
63 * \return Name of the application.
64 * \return \c NULL is \a app is \c NULL.
66 const char *app_name(const struct app *app);
69 * \brief Subscribe an application to a topic.
71 * \param app Application.
72 * \param topic Topic to subscribe to.
73 * \return New subscription.
74 * \return \c NULL on error.
76 struct stasis_subscription *app_subscribe(struct app *app,
77 struct stasis_topic *topic);
80 * \brief Send a message to an application.
82 * \param app Application.
83 * \param message Message to send.
85 void app_send(struct app *app, struct ast_json *message);
88 * \brief Send the start message to an application.
90 * \param app Application.
91 * \param chan The channel entering the application.
92 * \param argc The number of arguments for the application.
93 * \param argv The arguments for the application.
94 * \return 0 on success.
95 * \return Non-zero on error.
97 int app_send_start_msg(struct app *app, struct ast_channel *chan, int argc,
101 * \brief Send the end message to an application.
103 * \param app Application.
104 * \param chan The channel leaving the application.
105 * \return 0 on success.
106 * \return Non-zero on error.
108 int app_send_end_msg(struct app *app, struct ast_channel *chan);
111 * \brief Checks if an application is watching a given channel.
113 * \param app Application.
114 * \param uniqueid Uniqueid of the channel to check about.
115 * \return True (non-zero) if \a app is watching channel with given \a uniqueid
116 * \return False (zero) if \a app isn't.
118 int app_is_watching_channel(struct app *app, const char *uniqueid);
121 * \brief Add a channel to an application's watch list.
123 * \param app Application.
124 * \param chan Channel to watch.
125 * \return 0 on success.
126 * \return Non-zero on error.
128 int app_add_channel(struct app *app, const struct ast_channel *chan);
131 * \brief Remove a channel from an application's watch list.
133 * \param app Application.
134 * \param chan Channel to watch.
136 void app_remove_channel(struct app *app, const struct ast_channel *chan);
138 #endif /* _ASTERISK_RES_STASIS_APP_H */