1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
4 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5 <title>APE jQuery Test - Color Changer</title>
7 <script type="text/javascript" language="javascript" src="/js/vendor/jquery-1.9.1.min.js"></script>
8 <script type="text/javascript" language="javascript" src="/js/vendor/ape.js"></script>
9 <script type="text/javascript" language="javascript" src="/js/vendor/ape-config.js"></script>
12 <input id="chat" type="text"></input>
13 <button id="myButton" type="button">speaketh</button>
14 <button id="myButton2" type="button">who am i</button>
16 <div id="wrapper"></div>
23 <script type="text/javaScript">
25 $(document).ready(function() {
29 $('#myButton').click(function () {
31 apeChat.send($('#chat').val());
34 $('#myButton2').click(function () {
36 apeChat.request.send('whoami', {});
39 // create our new shiney APE client
40 var client = new APE.Client;
45 // set to false to disable debugging
48 // load the APE client
49 client.addEvent('load', function() {
50 //3) Call core start function to connect to APE Server, and prompt the user for a nickname
51 client.core.start({"name": prompt('Your name?'), "ident": 123456789});
54 // listen for ready event to know when we are connected
55 client.addEvent('ready', function() {
56 debug && console.log('Your client is now connected');
57 //1) join 'testChannel'
58 client.core.join('synchv1');
60 //2) Intercept multiPipeCreate event
61 client.addEvent('multiPipeCreate', function(pipe, options) {
62 //3) Send the message on the pipe
64 pipe.send('Hello world!');
65 debug && console.log('Sending Hello world');
68 //4) Intercept receipt of the new message.
69 client.onRaw('data', function(raw, pipe) {
70 alert(JSON.stringify(raw.data));
73 //5) Push messages from the server.
74 client.onRaw('postmsg', function(raw, pipe) {
75 alert(JSON.stringify(raw));
76 //alert(raw.data.message);
77 debug && console.log('Receiving : ' + unescape(raw.data.message));