work in progress: Dojo client for talk protocol with long-poll transport
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3848 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
c4a0d2a6d2
commit
6625abe012
1 changed files with 7 additions and 3 deletions
|
@ -32,6 +32,7 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.receiver = null;
|
this.receiver = null;
|
||||||
this.receiving = false;
|
this.receiving = false;
|
||||||
|
this.repeat_receiving = false;
|
||||||
this.id = (name == undefined | name == '' ? null : name);
|
this.id = (name == undefined | name == '' ? null : name);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,11 +50,12 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
receive: function(timeout) {
|
receive: function(repeat) {
|
||||||
if (this.receiving) {
|
if (this.receiving) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.receiving = true;
|
this.receiving = true;
|
||||||
|
this.repeat_receiving = repeat;
|
||||||
return dojo.xhrPost({
|
return dojo.xhrPost({
|
||||||
url: this.url + '/.talk/receive/' + this.id,
|
url: this.url + '/.talk/receive/' + this.id,
|
||||||
handleAs: 'json',
|
handleAs: 'json',
|
||||||
|
@ -82,7 +84,7 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
error: dojo.hitch(this, this._handleError),
|
error: dojo.hitch(this, this._handleError),
|
||||||
load: dojo.hitch(this, function(response, ioArgs) {
|
load: dojo.hitch(this, function(response, ioArgs) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
this.receiving = false;
|
this.repeat_receiving = false;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -95,7 +97,9 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.receiving = false;
|
this.receiving = false;
|
||||||
st = response.state;
|
if (this.repeat_receiving) {
|
||||||
|
receive(true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleReceiveError: function(response, ioArgs) {
|
_handleReceiveError: function(response, ioArgs) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue