| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \section{Asynchronous Javascript Asterisk Manger (AJAM)} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | AJAM is a new technology which allows web browsers or other HTTP enabled | 
					
						
							|  |  |  | applications and web pages to directly access the Asterisk Manger | 
					
						
							|  |  |  | Interface (AMI) via HTTP.  Setting up your server to process AJAM | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | involves a few steps: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Setup the Asterisk HTTP server} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{enumerate} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \item Uncomment the line "enabled=yes" in \path{/etc/asterisk/http.conf} to enable | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  |    Asterisk's builtin micro HTTP server. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \item If you want Asterisk to actually deliver simple HTML pages, CSS, | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  |    javascript, etc. you should uncomment "enablestatic=yes" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \item Adjust your "bindaddr" and "bindport" settings as appropriate for | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  |    your desired accessibility | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \item Adjust your "prefix" if appropriate, which must be the beginning of | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  |    any URI on the server to match.  The default is "asterisk" and the | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  |    rest of these instructions assume that value. | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{enumerate} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Allow Manager Access via HTTP} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{enumerate} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \item Make sure you have both "enabled = yes" and "webenabled = yes" setup | 
					
						
							|  |  |  |    in \path{/etc/asterisk/manager.conf} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \item You may also use "httptimeout" to set a default timeout for HTTP | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  |    connections. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \item Make sure you have a manager username/secret | 
					
						
							|  |  |  | \end{enumerate} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | Once those configurations are complete you can reload or restart | 
					
						
							|  |  |  | Asterisk and you should be able to point your web browser to specific | 
					
						
							|  |  |  | URI's which will allow you to access various web functions.  A complete | 
					
						
							|  |  |  | list can be found by typing "http show status" at the Asterisk CLI. | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | examples: | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							|  |  |  | http://localhost:8088/asterisk/manager?action=login&username=foo&secret=bar | 
					
						
							|  |  |  | \end{verbatim} | 
					
						
							|  |  |  | \end{astlisting} | 
					
						
							|  |  |  | This logs you into the manager interface's "HTML" view.  Once you're | 
					
						
							|  |  |  | logged in, Asterisk stores a cookie on your browser (valid for the | 
					
						
							|  |  |  | length of httptimeout) which is used to connect to the same session. | 
					
						
							|  |  |  | \begin{astlisting} | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | http://localhost:8088/asterisk/rawman?action=status | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{verbatim} | 
					
						
							|  |  |  | \end{astlisting} | 
					
						
							|  |  |  | Assuming you've already logged into manager, this URI will give you a | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | "raw" manager output for the "status" command. | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | http://localhost:8088/asterisk/mxml?action=status | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{verbatim} | 
					
						
							|  |  |  | \end{astlisting} | 
					
						
							|  |  |  | This will give you the same status view but represented as AJAX data, | 
					
						
							|  |  |  | theoretically compatible with RICO (\url{http://www.openrico.org}). | 
					
						
							|  |  |  | \begin{astlisting} | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | http://localhost:8088/asterisk/static/ajamdemo.html | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{verbatim} | 
					
						
							|  |  |  | \end{astlisting} | 
					
						
							|  |  |  | If you have enabled static content support and have done a make install, | 
					
						
							|  |  |  | Asterisk will serve up a demo page which presents a live, but very | 
					
						
							|  |  |  | basic, "astman" like interface.  You can login with your username/secret | 
					
						
							|  |  |  | for manager and have a basic view of channels as well as transfer and | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | hangup calls.  It's only tested in Firefox, but could probably be made | 
					
						
							|  |  |  | to run in other browsers as well. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | A sample library (astman.js) is included to help ease the creation of | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | manager HTML interfaces. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Note that for the demo, there is no need for *any* external web server. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsection{Integration with other web servers} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | Asterisk's micro HTTP server is *not* designed to replace a general | 
					
						
							|  |  |  | purpose web server and it is intentionally created to provide only the | 
					
						
							|  |  |  | minimal interfaces required.  Even without the addition of an external | 
					
						
							|  |  |  | web server, one can use Asterisk's interfaces to implement screen pops | 
					
						
							|  |  |  | and similar tools pulling data from other web servers using iframes, | 
					
						
							|  |  |  | div's etc.  If you want to integrate CGI's, databases, PHP, etc.  you | 
					
						
							|  |  |  | will likely need to use a more traditional web server like Apache and | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | link in your Asterisk micro HTTP server with something like this: | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							|  |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2006-04-01 08:49:54 +00:00
										 |  |  | ProxyPass /asterisk http://localhost:8088/asterisk | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{verbatim} | 
					
						
							|  |  |  | \end{astlisting} | 
					
						
							|  |  |  | 
 |