projects
/
euphorik.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
MOD maj TODO.txt
[euphorik.git]
/
js
/
euphorik.js
diff --git
a/js/euphorik.js
b/js/euphorik.js
index
825e4c3
..
f330209
100755
(executable)
--- a/
js/euphorik.js
+++ b/
js/euphorik.js
@@
-994,6
+994,16
@@
Client.prototype.kick = function(userId, raison)
/**
* classe permettant de gérer les événements (push serveur).
/**
* classe permettant de gérer les événements (push serveur).
+ * l'information envoyé est sous la forme :
+ * {
+ * "action" : "wait_event"
+ * "page" : <page>
+ * [..]
+ * }
+ * l'information reçu est sous la forme :
+ * {
+ * "reply" : <reply>
+ * }
* @page la page
*/
function PageEvent(page, util)
* @page la page
*/
function PageEvent(page, util)
@@
-1024,9
+1034,11
@@
PageEvent.prototype.stopAttenteCourante = function()
/**
* Attend un événement lié à la page.
* @funSend une fonction renvoyant les données json à envoyer
/**
* Attend un événement lié à la page.
* @funSend une fonction renvoyant les données json à envoyer
- * @funReceive une fonction qui accepte un paramètre correspondant au données reçues
+ * @funsReceive est un objet comprenant les fonctions à appeler en fonction du "reply"
+ * les fonctions acceptent un paramètre correspondant au données reçues.
+ * exemple : {"new_message" : function(data){ ... }}
*/
*/
-PageEvent.prototype.waitEvent = function(funSend, funReceive)
+PageEvent.prototype.waitEvent = function(funSend, fun
s
Receive)
{
this.stopAttenteCourante()
{
this.stopAttenteCourante()
@@
-1050,22
+1062,24
@@
PageEvent.prototype.waitEvent = function(funSend, funReceive)
this.attenteCourante = jQuery.ajax({
type: "POST",
url: "request",
this.attenteCourante = jQuery.ajax({
type: "POST",
url: "request",
- dataType: "json",
+ dataType: "json",
\r
+ timeout: 300000, // timeout de 5min. Gros HACK pas beau. FIXME problème décrit ici : http://groups.google.com/group/jquery-en/browse_thread/thread/8724e64af3333a76
data: this.util.jsonVersAction(dataToSend),
success:
function(data)
{
;; dumpObj(data)
data: this.util.jsonVersAction(dataToSend),
success:
function(data)
{
;; dumpObj(data)
- fun
Receive
(data)
+ fun
sReceive[data["reply"]]
(data)
// rappel de la fonction dans 100 ms
// rappel de la fonction dans 100 ms
- setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funReceive) }, 100)
+ setTimeout(function(){ thisPageEvent.waitEvent2(funSend, fun
s
Receive) }, 100)
},
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
},
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
- setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funReceive) }, 1000)
+ ;; console.log("Connexion perdue dans waitEvent")
+ setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funsReceive) }, 1000)
}
})
}
}
})
}
@@
-1073,11
+1087,11
@@
PageEvent.prototype.waitEvent = function(funSend, funReceive)
/**
* Si un stopAttenteCourante survient un peu n'importe quand il faut imédiatement arreter de boucler.
*/
/**
* Si un stopAttenteCourante survient un peu n'importe quand il faut imédiatement arreter de boucler.
*/
-PageEvent.prototype.waitEvent2 = function(funSend, funReceive)
+PageEvent.prototype.waitEvent2 = function(funSend, fun
s
Receive)
{
if (this.stop)
return
{
if (this.stop)
return
- this.waitEvent(funSend, funReceive)
+ this.waitEvent(funSend, fun
s
Receive)
}
///////////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////