Created
February 16, 2012 16:34
-
-
Save bazo/1846280 to your computer and use it in GitHub Desktop.
ape client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var apeConfig = { | |
domain: 'auto', | |
server: 'server.com:6969', | |
transport: 1, | |
} | |
var baseUrl = 'http://' + window.location.hostname; | |
if(window.location.port != 80) | |
{ | |
baseUrl += ':'+window.location.port; | |
} | |
APE.Config.baseUrl = baseUrl + '/js/ape'; | |
var scripts = ['mootools-core', 'Core/APE', 'Core/Events', 'Core/Core', 'Pipe/Pipe', 'Pipe/PipeProxy', | |
'Pipe/PipeMulti', 'Pipe/PipeSingle', 'Request/Request','Request/Request.Stack', | |
'Request/Request.CycledStack', 'Transport/Transport.longPolling','Transport/Transport.SSE', | |
'Transport/Transport.XHRStreaming', 'Transport/Transport.JSONP', 'Transport/Transport.WebSocket', | |
'Core/Utility', 'Core/JSON']; | |
for (var i = 0; i < scripts.length; i++) | |
{ | |
APE.Config.scripts.push(APE.Config.baseUrl + '/Source/' + scripts[i] + '.js'); | |
} | |
$(document).ready(function(){ | |
var client = new APE.Client(); | |
client.onCmd('ready', function(data) { | |
console.log('ready'); | |
//Join two channels | |
client.core.join('testChannel'); | |
}); | |
//client.request.send('foo', { ping: 'ho hey'}); | |
client.onRaw('bar', function(raw, pipe) { | |
console.log('echo : ' + raw.data.echo); | |
console.log('Receiving : ' + raw.data.hello); | |
}); | |
client.load(apeConfig); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment