blob: d593442879832eb76e37b6e66d34232e4e44d751 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001<html>
2 <head>
3 <script src="https://apprtc.appspot.com/_ah/channel/jsapi"></script>
4 </head>
5 <!--
6 Helper HTML that redirects Google AppEngine's Channel API to a JS object named
7 |androidMessageHandler|, which is expected to be injected into the WebView
fischman@webrtc.org147d44a2013-07-29 19:07:33 +00008 rendering this page by an Android app's class such as AppRTCClient.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 -->
10 <body onbeforeunload="closeSocket()" onload="openSocket()">
11 <script type="text/javascript">
fischman@webrtc.org147d44a2013-07-29 19:07:33 +000012 var token = androidMessageHandler.getToken();
13 if (!token)
14 throw "Missing/malformed token parameter: [" + token + "]";
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015
16 var channel = null;
17 var socket = null;
18
19 function openSocket() {
fischman@webrtc.org147d44a2013-07-29 19:07:33 +000020 channel = new goog.appengine.Channel(token);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000021 socket = channel.open({
22 'onopen': function() { androidMessageHandler.onOpen(); },
23 'onmessage': function(msg) { androidMessageHandler.onMessage(msg.data); },
24 'onclose': function() { androidMessageHandler.onClose(); },
25 'onerror': function(err) { androidMessageHandler.onError(err.code, err.description); }
26 });
27 }
28
29 function closeSocket() {
30 socket.close();
31 }
32 </script>
33 </body>
34</html>