work in progress: jocy.talk JavaScript library

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3487 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-08-01 19:56:15 +00:00
parent 968c988a1c
commit a54bec4da7

View file

@ -24,7 +24,9 @@
dojo.provide('jocy.talk');
dojo.declare('jocy.talk.Connection', null, {
info: 'jocy.talk Connection',
constructor: function(url, client, user, password){
this.url = url.replace(/\/$/, '');
@ -45,6 +47,8 @@ dojo.declare('jocy.talk.Connection', null, {
this._cometdInitialized = false;
}
},
// ReST methods
get: function(resourcePath, data, cbName, user, password) {
return dojo.xhrGet({
url: this._setupUrl(resourcePath),
@ -102,20 +106,25 @@ dojo.declare('jocy.talk.Connection', null, {
},
});
},
// cometd methods
publish: function(channel, data) {
this.initComed();
this.initCometd();
dojox.cometd.publish(channel, data);
},
subscribe: function(channel, callback){
this.initComed();
dojox.cometd.subscribe(channel, this, callback);
subscribe: function(channel, cbName){
this.initCometd();
dojox.cometd.subscribe(channel, this.client, cbName);
},
// private methods
_setupObjectPath: function(path) {
slash = (path.charAt(0) == '/' ? '' : '/');
return this.url + slash + path;
},
_callback: function(data, cbName) {
this.client[cbName](data);
_callback: function(response, ioArgs, cbName) {
this.client[cbName](response);
return response;
},
/* dojox.cometd example */