2013-07-10 02:45:36 +02:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script src="https://apprtc.appspot.com/_ah/channel/jsapi"></script>
|
|
|
|
</head>
|
|
|
|
<!--
|
|
|
|
Helper HTML that redirects Google AppEngine's Channel API to a JS object named
|
|
|
|
|androidMessageHandler|, which is expected to be injected into the WebView
|
2013-07-29 21:07:33 +02:00
|
|
|
rendering this page by an Android app's class such as AppRTCClient.
|
2013-07-10 02:45:36 +02:00
|
|
|
-->
|
|
|
|
<body onbeforeunload="closeSocket()" onload="openSocket()">
|
|
|
|
<script type="text/javascript">
|
2013-07-29 21:07:33 +02:00
|
|
|
var token = androidMessageHandler.getToken();
|
|
|
|
if (!token)
|
|
|
|
throw "Missing/malformed token parameter: [" + token + "]";
|
2013-07-10 02:45:36 +02:00
|
|
|
|
|
|
|
var channel = null;
|
|
|
|
var socket = null;
|
|
|
|
|
|
|
|
function openSocket() {
|
2013-07-29 21:07:33 +02:00
|
|
|
channel = new goog.appengine.Channel(token);
|
2013-07-10 02:45:36 +02:00
|
|
|
socket = channel.open({
|
|
|
|
'onopen': function() { androidMessageHandler.onOpen(); },
|
|
|
|
'onmessage': function(msg) { androidMessageHandler.onMessage(msg.data); },
|
|
|
|
'onclose': function() { androidMessageHandler.onClose(); },
|
|
|
|
'onerror': function(err) { androidMessageHandler.onError(err.code, err.description); }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeSocket() {
|
|
|
|
socket.close();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|