Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 60 lines (49 sloc) 1.32 KB
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>websocket-android-phonegap</title>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"></script>
<script type="text/javascript" charset="utf-8" src="js/websocket.js"></script>
</head>
<body>
WebSocket test page!
<pre>
[code]
// new socket
var socket = new WebSocket('ws://122.168.196.27:8081/');
// push a message after the connection is established.
socket.onopen = function() {
socket.send('Hello World')
};
// alerts message pushed from server
socket.onmessage = function(msg) {
alert(JSON.stringify(msg));
};
// alert close event
socket.onclose = function() {
alert('closed');
};
[/code]
</pre>
</body>
<script type="text/javascript" charset="utf-8">
// new socket
var socket = new WebSocket('ws://122.168.196.27:8081/');
// push a message after the connection is established.
socket.onopen = function() {
socket.send('Hello World')
};
// alerts message pushed from server
socket.onmessage = function(msg) {
alert(JSON.stringify(msg));
};
// alert close event
socket.onclose = function() {
alert('closed');
};
// now, close the connection after 10 secons. (funny!)
/* setInterval(function() {
socket.close();
}, 10000); */
</script>
</html>