From 0cb79aabb286a5820f34064c7d7ff1d29ae72c9b Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 23 Aug 2009 09:09:24 +0000 Subject: [PATCH] work in progess: client communication API git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3514 fd906abe-77d9-0310-91a1-e0d9ade77398 --- ajax/jocy/talk.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/ajax/jocy/talk.js b/ajax/jocy/talk.js index 6fbda2a..cb24ccd 100644 --- a/ajax/jocy/talk.js +++ b/ajax/jocy/talk.js @@ -50,23 +50,19 @@ dojo.declare('jocy.talk.Connection', null, { // ReST methods get: function(resourcePath, data, cbName, user, password) { - //return dojo.io.script.get({ - // callbackParamName: 'jsonp', return dojo.xhrGet({ url: this._setupUrl(resourcePath), - load: function(response, ioArgs) { + load: dojo.hitch(this, function(response, ioArgs) { return this._callback(response, ioArgs, cbName); - }, + }), content: data, handleAs: 'json', user: user, password: password }); }, - getSynchronous: function(resourcePath, data, cbName) { + getSynchronous: function(resourcePath, data) { var result = {}; - //dojo.io.script.get({ - // callbackParamName: 'jsonp', dojo.xhrGet({ url: this._setupUrl(resourcePath), load: function(response, ioArgs) { @@ -84,18 +80,18 @@ dojo.declare('jocy.talk.Connection', null, { put: function(resourcePath, data, cbName) { return dojo.xhrPut({ url: this._setupU(cbName), - load: function(response, ioArgs) { + load: dojo.hitch(this, function(response, ioArgs) { return this._callback(response, ioArgs, cbName); - }, + }), putData: dojo.toJson(data), }); }, post: function(resourcePath, data, cbName) { return dojo.xhrGet({ url: this._setupUrl(resourcePath), - load: function(response, ioArgs) { + load: dojo.hitch(this, function(response, ioArgs) { return this._callback(response, ioArgs, cbName); - }, + }), postData: dojo.toJson(data) }); }, @@ -105,24 +101,24 @@ dojo.declare('jocy.talk.Connection', null, { remove: function(resourcePath, cbName) { return dojo.xhrDelete({ url: this._setupU(resourcePath), - load: function(response, ioArgs) { + load: dojo.hitch(this, function(response, ioArgs) { return this._callback(response, ioArgs, cbName); - }, + }), }); }, // cometd methods publish: function(channel, data) { this.initCometd(); - dojox.cometd.publish(channel, data); + return dojox.cometd.publish(channel, data); }, subscribe: function(channel, cbName){ this.initCometd(); - dojox.cometd.subscribe(channel, this.client, cbName); + return dojox.cometd.subscribe(channel, this.client, cbName); }, unsubscribe: function(channel){ this.initCometd(); - dojox.cometd.unsubscribe(channel, this.client); + return dojox.cometd.unsubscribe(channel, this.client); }, // private methods