kopia lustrzana https://github.com/c9/core
Make new serverPing logic backward & forward compatible
rodzic
6f197414c3
commit
c7ec9d7b4f
|
@ -327,7 +327,7 @@ function Worker(vfs) {
|
|||
* Add additional timing info to any "ping" call.
|
||||
*/
|
||||
function wrapPingCall(name, fnName, args) {
|
||||
if (name === "ping" && fnName === "ping" && args.length === 2) {
|
||||
if (name === "ping" && fnName === "ping" && args[0] === "serverTime" && args.length === 2) {
|
||||
var start = Date.now();
|
||||
var cb = args[1];
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module.exports = function(vfs, options, register) {
|
||||
register(null, {
|
||||
ping: function (payload, callback) {
|
||||
// We simply return the payload, while vfs-socket adds a time stamp
|
||||
callback(null, payload);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -60,13 +60,12 @@ define(function(require, exports, module) {
|
|||
if (!api) return callback(new Error("Client is offline"));
|
||||
|
||||
var start = Date.now();
|
||||
api.ping("ping", function(err, response) {
|
||||
var took = Date.now() - start;
|
||||
api.ping("serverTime", function(err, response) {
|
||||
if (err) return callback(err);
|
||||
|
||||
callback(null, {
|
||||
serverTime: response.serverTime,
|
||||
total: took
|
||||
total: Date.now() - start
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue