Merged revisions 140169 via svnmerge from
[asterisk-bristuff.git] / doc / tex / ajam.tex
blob3421cc0ed08a82bd72b54d9223e6952a628435a2
1 \section{Asynchronous Javascript Asterisk Manger (AJAM)}
3 AJAM is a new technology which allows web browsers or other HTTP enabled
4 applications and web pages to directly access the Asterisk Manger
5 Interface (AMI) via HTTP. Setting up your server to process AJAM
6 involves a few steps:
8 \subsection{Setup the Asterisk HTTP server}
10 \begin{enumerate}
11 \item Uncomment the line "enabled=yes" in \path{/etc/asterisk/http.conf} to enable
12 Asterisk's builtin micro HTTP server.
14 \item If you want Asterisk to actually deliver simple HTML pages, CSS,
15 javascript, etc. you should uncomment "enablestatic=yes"
17 \item Adjust your "bindaddr" and "bindport" settings as appropriate for
18 your desired accessibility
20 \item Adjust your "prefix" if appropriate, which must be the beginning of
21 any URI on the server to match. The default is "asterisk" and the
22 rest of these instructions assume that value.
23 \end{enumerate}
25 \subsection{Allow Manager Access via HTTP}
27 \begin{enumerate}
28 \item Make sure you have both "enabled = yes" and "webenabled = yes" setup
29 in \path{/etc/asterisk/manager.conf}
31 \item You may also use "httptimeout" to set a default timeout for HTTP
32 connections.
34 \item Make sure you have a manager username/secret
35 \end{enumerate}
37 Once those configurations are complete you can reload or restart
38 Asterisk and you should be able to point your web browser to specific
39 URI's which will allow you to access various web functions. A complete
40 list can be found by typing "http show status" at the Asterisk CLI.
42 examples:
43 \begin{astlisting}
44 \begin{verbatim}
45 http://localhost:8088/asterisk/manager?action=login&username=foo&secret=bar
46 \end{verbatim}
47 \end{astlisting}
48 This logs you into the manager interface's "HTML" view. Once you're
49 logged in, Asterisk stores a cookie on your browser (valid for the
50 length of httptimeout) which is used to connect to the same session.
51 \begin{astlisting}
52 \begin{verbatim}
53 http://localhost:8088/asterisk/rawman?action=status
54 \end{verbatim}
55 \end{astlisting}
56 Assuming you've already logged into manager, this URI will give you a
57 "raw" manager output for the "status" command.
58 \begin{astlisting}
59 \begin{verbatim}
60 http://localhost:8088/asterisk/mxml?action=status
61 \end{verbatim}
62 \end{astlisting}
63 This will give you the same status view but represented as AJAX data,
64 theoretically compatible with RICO (\url{http://www.openrico.org}).
65 \begin{astlisting}
66 \begin{verbatim}
67 http://localhost:8088/asterisk/static/ajamdemo.html
68 \end{verbatim}
69 \end{astlisting}
70 If you have enabled static content support and have done a make install,
71 Asterisk will serve up a demo page which presents a live, but very
72 basic, "astman" like interface. You can login with your username/secret
73 for manager and have a basic view of channels as well as transfer and
74 hangup calls. It's only tested in Firefox, but could probably be made
75 to run in other browsers as well.
77 A sample library (astman.js) is included to help ease the creation of
78 manager HTML interfaces.
80 Note that for the demo, there is no need for *any* external web server.
82 \subsection{Integration with other web servers}
84 Asterisk's micro HTTP server is *not* designed to replace a general
85 purpose web server and it is intentionally created to provide only the
86 minimal interfaces required. Even without the addition of an external
87 web server, one can use Asterisk's interfaces to implement screen pops
88 and similar tools pulling data from other web servers using iframes,
89 div's etc. If you want to integrate CGI's, databases, PHP, etc. you
90 will likely need to use a more traditional web server like Apache and
91 link in your Asterisk micro HTTP server with something like this:
92 \begin{astlisting}
93 \begin{verbatim}
94 ProxyPass /asterisk http://localhost:8088/asterisk
95 \end{verbatim}
96 \end{astlisting}