Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 97485a2

Browse files
committed
Merge pull request #509 from adobe/zaggino/domain-progress
implement sendCommandProgress and progress callback
2 parents f90c599 + 521d3ba commit 97485a2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

appshell/node-core/ConnectionManager.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ maxerr: 50, node: true */
171171
}
172172
};
173173

174+
/**
175+
* Sends a progress message to command execution (async commands only)
176+
* @param {number} id unique ID of the command that was executed. ID is
177+
* generated by the client when the command is issued.
178+
* @param {string} message Progress message
179+
*/
180+
Connection.prototype.sendCommandProgress = function (id, message) {
181+
this._send("commandProgress", {id: id, message: message});
182+
};
183+
174184
/**
175185
* Sends a response indicating that an error occurred during command
176186
* execution

appshell/node-core/DomainManager.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ maxerr: 50, node: true */
148148
* @param {string} domainName The domain name.
149149
* @param {string} commandName The command name.
150150
* @param {Array} parameters The parameters to pass to the command function. If
151-
* the command is asynchronous, will be augmented with a callback function.
151+
* the command is asynchronous, will be augmented with a callback function
152+
* and progressCallback function
152153
* (see description in registerCommand documentation)
153154
*/
154155
function executeCommand(connection, id, domainName,
@@ -164,7 +165,10 @@ maxerr: 50, node: true */
164165
connection.sendCommandResponse(id, result);
165166
}
166167
};
167-
parameters.push(callback);
168+
var progressCallback = function (msg) {
169+
connection.sendCommandProgress(id, msg);
170+
};
171+
parameters.push(callback, progressCallback);
168172
command.commandFunction.apply(connection, parameters);
169173
} else { // synchronous command
170174
try {

0 commit comments

Comments
 (0)