Skip to content

Commit

Permalink
connection: Some updates to HTTP and WS handling
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Nov 25, 2016
1 parent f0af69f commit 69549eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/client/javascript/core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@
} else if ( (API.getConfig('Connection.Type') === 'standalone') ) {
cbError('You are currently running locally and cannot perform this operation!');
} else {
if ( method.match(/^FS/) ) {
return this._requestVFS(method, args, options, cbSuccess, cbError);
if ( method.match(/^FS:/) ) {
return this._requestVFS(method.replace(/^FS:/, ''), args, options, cbSuccess, cbError);
}
return this._requestAPI(method, args, options, cbSuccess, cbError);
}
Expand Down Expand Up @@ -305,16 +305,6 @@
* @return {Boolean}
*/
Connection.prototype._request = function(isVfs, method, args, options, onsuccess, onerror) {
// Some methods can only be handled via HTTP
if ( isVfs ) {
if ( method === 'FS:get' ) {
return this.callGET(args, options, onsuccess, onerror);
} else if ( method === 'FS:upload' ) {
return this.callPOST(args, options, onsuccess, onerror);
}
}

// Use AJAX or WebSocket for everything else
var url = (function() {
if ( isVfs ) {
return API.getConfig('Connection.FSURI') + '/' + method.replace(/^FS\:/, '');
Expand Down
13 changes: 11 additions & 2 deletions src/client/javascript/core/connections/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,27 @@
}
};

WSConnection.prototype.request = function(path, args, options, onsuccess, onerror) {
WSConnection.prototype._request = function(isVfs, method, args, options, onsuccess, onerror) {
onerror = onerror || function() {
console.warn('Connection::callWS()', 'error', arguments);
};

if ( isVfs ) {
if ( method === 'get' ) {
return this.callGET(args, options, onsuccess, onerror);
} else if ( method === 'upload' ) {
return this.callPOST(args, options, onsuccess, onerror);
}
}

var idx = this.index++;
var base = isVfs ? '/FS/' : '/API/';

try {
this.ws.send(JSON.stringify({
_index: idx,
sid: Utils.getCookie('session'),
path: '/' + path,
path: base + method,
args: args
}));

Expand Down

0 comments on commit 69549eb

Please sign in to comment.