function onInit() { rpc.register("doSomethingLong", doSomethingLong) } function doSomethingLong(ctx, params) { var start = Date.now() while (true) { var now = Date.now() if (now - start >= params.delay) break } return params.i; }