Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1
Service and Server Monitoring | 103

function doStatus( event )
{
var elem = document.createElement( "div" );

elem.innerText = monitor.available;

document.body.appendChild( elem );
}
</script>

</head>
<body onload="doLoad( )">

</body>
</html>

Monitoring Connectivity to a Jabber Server


Problem


AJabber chat client is required to reflect network presence in
the user interface, but the endpoint is a Jabber server on a
specific port and not HTTP/S.


Solution


Use theSocketMonitorclass to detect network state changes
against TCP/IP socket endpoints.


Discussion


The service monitoring API is not built into Adobe AIR
directly, and needs to be added before it can be used. The
servicemonitor.swffile, which is included in the Adobe AIR
SDK, must be included as an application resource and
included via an HTML SCRIPT tag:


<script src="servicemonitor.swf"></script>

TheSocketMonitorclass takes two arguments in the con-
structor: a String that represents the host endpoint, and a
port on which the server is listening:


var host = "im.mydomain.com";
var port = 5220;
Free download pdf