work in progess: client communication API
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3514 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
d021473fbf
commit
0cb79aabb2
1 changed files with 12 additions and 16 deletions
|
@ -50,23 +50,19 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
|
|
||||||
// ReST methods
|
// ReST methods
|
||||||
get: function(resourcePath, data, cbName, user, password) {
|
get: function(resourcePath, data, cbName, user, password) {
|
||||||
//return dojo.io.script.get({
|
|
||||||
// callbackParamName: 'jsonp',
|
|
||||||
return dojo.xhrGet({
|
return dojo.xhrGet({
|
||||||
url: this._setupUrl(resourcePath),
|
url: this._setupUrl(resourcePath),
|
||||||
load: function(response, ioArgs) {
|
load: dojo.hitch(this, function(response, ioArgs) {
|
||||||
return this._callback(response, ioArgs, cbName);
|
return this._callback(response, ioArgs, cbName);
|
||||||
},
|
}),
|
||||||
content: data,
|
content: data,
|
||||||
handleAs: 'json',
|
handleAs: 'json',
|
||||||
user: user,
|
user: user,
|
||||||
password: password
|
password: password
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getSynchronous: function(resourcePath, data, cbName) {
|
getSynchronous: function(resourcePath, data) {
|
||||||
var result = {};
|
var result = {};
|
||||||
//dojo.io.script.get({
|
|
||||||
// callbackParamName: 'jsonp',
|
|
||||||
dojo.xhrGet({
|
dojo.xhrGet({
|
||||||
url: this._setupUrl(resourcePath),
|
url: this._setupUrl(resourcePath),
|
||||||
load: function(response, ioArgs) {
|
load: function(response, ioArgs) {
|
||||||
|
@ -84,18 +80,18 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
put: function(resourcePath, data, cbName) {
|
put: function(resourcePath, data, cbName) {
|
||||||
return dojo.xhrPut({
|
return dojo.xhrPut({
|
||||||
url: this._setupU(cbName),
|
url: this._setupU(cbName),
|
||||||
load: function(response, ioArgs) {
|
load: dojo.hitch(this, function(response, ioArgs) {
|
||||||
return this._callback(response, ioArgs, cbName);
|
return this._callback(response, ioArgs, cbName);
|
||||||
},
|
}),
|
||||||
putData: dojo.toJson(data),
|
putData: dojo.toJson(data),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
post: function(resourcePath, data, cbName) {
|
post: function(resourcePath, data, cbName) {
|
||||||
return dojo.xhrGet({
|
return dojo.xhrGet({
|
||||||
url: this._setupUrl(resourcePath),
|
url: this._setupUrl(resourcePath),
|
||||||
load: function(response, ioArgs) {
|
load: dojo.hitch(this, function(response, ioArgs) {
|
||||||
return this._callback(response, ioArgs, cbName);
|
return this._callback(response, ioArgs, cbName);
|
||||||
},
|
}),
|
||||||
postData: dojo.toJson(data)
|
postData: dojo.toJson(data)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -105,24 +101,24 @@ dojo.declare('jocy.talk.Connection', null, {
|
||||||
remove: function(resourcePath, cbName) {
|
remove: function(resourcePath, cbName) {
|
||||||
return dojo.xhrDelete({
|
return dojo.xhrDelete({
|
||||||
url: this._setupU(resourcePath),
|
url: this._setupU(resourcePath),
|
||||||
load: function(response, ioArgs) {
|
load: dojo.hitch(this, function(response, ioArgs) {
|
||||||
return this._callback(response, ioArgs, cbName);
|
return this._callback(response, ioArgs, cbName);
|
||||||
},
|
}),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// cometd methods
|
// cometd methods
|
||||||
publish: function(channel, data) {
|
publish: function(channel, data) {
|
||||||
this.initCometd();
|
this.initCometd();
|
||||||
dojox.cometd.publish(channel, data);
|
return dojox.cometd.publish(channel, data);
|
||||||
},
|
},
|
||||||
subscribe: function(channel, cbName){
|
subscribe: function(channel, cbName){
|
||||||
this.initCometd();
|
this.initCometd();
|
||||||
dojox.cometd.subscribe(channel, this.client, cbName);
|
return dojox.cometd.subscribe(channel, this.client, cbName);
|
||||||
},
|
},
|
||||||
unsubscribe: function(channel){
|
unsubscribe: function(channel){
|
||||||
this.initCometd();
|
this.initCometd();
|
||||||
dojox.cometd.unsubscribe(channel, this.client);
|
return dojox.cometd.unsubscribe(channel, this.client);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private methods
|
// private methods
|
||||||
|
|
Loading…
Add table
Reference in a new issue