Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
135 lines (130 sloc) 4.69 KB
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tropo Websocket Demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
<script src="http://dl.dropbox.com/u/25511/javascripts/strophe.js" type="text/javascript" charset="utf-8"></script>
<script src="http://dl.dropbox.com/u/25511/javascripts/artisan.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var BOSH_SERVICE = 'http://bosh.metajack.im:5280/xmpp-httpbind';
var connection = null;
function log(msg)
{
$('#log').append('<div></div>').append(document.createTextNode(msg));
}
function onConnect(status)
{
if (status == Strophe.Status.CONNECTING) {
log('Strophe is connecting.');
} else if (status == Strophe.Status.CONNFAIL) {
log('Strophe failed to connect.');
$('#connect').get(0).value = 'connect';
} else if (status == Strophe.Status.DISCONNECTING) {
log('Strophe is disconnecting.');
} else if (status == Strophe.Status.DISCONNECTED) {
log('Strophe is disconnected.');
$('#connect').get(0).value = 'connect';
} else if (status == Strophe.Status.CONNECTED) {
log('Strophe is connected.');
connection.addHandler(onMessage, null, 'message', null, null, null);
connection.send($pres().tree());
}
}
function onMessage(msg) {
var elems = msg.getElementsByTagName('body');
var body = elems[0];
var response = JSON.parse(Strophe.getText(body));
switch(response.command) {
case '1':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/85fedec1-b9fc-423b-a124-9c2a00bdea99.jpg',
10,
30,
100,
100);
break;
case '2':
artisan.drawImage('drawspace',
'http://manishapatnaik.files.wordpress.com/2009/11/number-2.jpg',
120,
30,
100,
100);
break;
case '3':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/682ebd6b-d93b-406d-a8c1-9c2a00bdd886.jpg',
240,
30,
100,
100);
break;
case '4':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/5dadd9a2-c5f0-4bc0-92e4-9c2a00bdff61.jpg',
10,
150,
100,
100);
break;
case '5':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/213060f9-ef34-45fb-81e7-9c2a00bdd780.jpg',
120,
150,
100,
100);
break;
case '6':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/2af8d401-99b3-4b54-ab1b-9c2a00bdc56d.jpg',
240,
150,
100,
100);
break;
case '7':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/ef8e67ad-c9cd-4823-a10f-9c2a00bdf1d4.jpg',
10,
270,
100,
100);
break;
case '8':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/46a3359b-beff-4f50-8d05-9c2a00bdc933.jpg',
120,
270,
100,
100);
break;
case '9':
artisan.drawImage('drawspace',
'http://comcastchd.vo.llnwd.net/o15/resized/1389a698-fd6e-44ee-af03-9c2a00be0c4e.jpg',
240,
270,
100,
100);
break;
default:
artisan.drawText('drawspace', 390, 150, 'Goodbye!');
}
return true;
}
$(document).ready(function () {
connection = new Strophe.Connection(BOSH_SERVICE);
connection.connect('user', 'pass', onConnect);
});
</script>
</head>
<body>
<img src="http://voxeo-labs.s3.amazonaws.com/Tropo-Horiz_200.png" height="" width=""></img>
<h1>XMPP/BOSH Demonstration</h1>
<div id='log'></div>
<canvas id='drawspace' width='1000' height='1000'>
<p>Your browser doesn't support canvas.</p>
</canvas>
</body>
</html>