1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
var Network = Class.create({
initialize: function(){
this.latence = 0;
this.time = 0;
this.delta = 0;
},
sync:function(){
var e = jQuery.Event("speack", { msg: "sync" });
this.send(e);
this.time = new Date();
},
send: function(event){
new Ajax.Request('index.php/game/'+event.type,
{
method:'post',
parameters: {cmd: event.msg},
onSuccess: function(transport){
var response = transport.responseText || "vide";
//lien vers Network.onData(response);
},
onFailure: function(){ alert('Server maybe down...') }
});
},
onData: function(response){
console.log("Success!" + response);
}
}); |