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