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:
parent
968c988a1c
commit
a54bec4da7
1 changed files with 15 additions and 6 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue