How to use the scheduler.later function in scheduler

To help you get started, we’ve selected a few scheduler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tjanczuk / denser / src / denser / samples / chat2.js View on Github external
}
            }
        };
    }
    else { // serve HTML UI 
        request.onEnd = function () {
            request.onWriteReady = function () { request.writeBody(chatui.htmlForMultitenancy, true); };
            request.writeHeaders(200, "OK", { "Content-type": "text/html", "Content-length": chatui.htmlForMultitenancy.length.toString(), "Cache-Control": "no-cache" }, false);
        }
    }
    request.readMore();
}

http.createServer({ url: "http://*:80/chat/" + programId, onNewRequest: chatHttpHandler }).start(); // start message and UI server

scheduler.later(publishUsageUpdate, 10000, true); // publish usage statistics every 10 seconds

scheduleDanteQuote(); // schedule a post of Dante's Divine Comedy (Cante I, The Inferno)

publishUsageUpdate(); // publish once on startup to ensure every new client receives an immediate update

tracing.write("Chat started at http://localhost/chat/" + programId);
github tjanczuk / denser / src / denser / samples / chat2.js View on Github external
request.onEnd = function (event) {
            if ("POST" === request.verb) { // publish message   
                publishMessage(bufferedBody, "text/plain");
                request.writeHeaders(200, "OK", {}, true);
            }
            else { // HTTP long poll for messages
                if (!releasePoll(request)) {
                    polls[request.requestSlot] = {
                        request: request,
                        timer: scheduler.later(function () { timeoutPoll(request.requestSlot); }, 15000)
                    };
                }
            }
        };
    }
github tjanczuk / denser / src / denser / samples / chat2.js View on Github external
function scheduleDanteQuote() {
    scheduler.later(
        function () {
            publishMessage(dante.getNextLine(), "text/plain");
            scheduleDanteQuote();
        },
        200);
        //5000 + Math.floor(4000 * Math.random()));
}