Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

service

Process requests


Description

Process HTTP requests and WebSocket messages. If there is nothing on R's call stack – if R is sitting idle at the command prompt – it is not necessary to call this function, because requests will be handled automatically. However, if R is executing code, then requests will not be handled until either the call stack is empty, or this function is called (or alternatively, run_now is called).

Usage

service(timeoutMs = ifelse(interactive(), 100, 1000))

Arguments

timeoutMs

Approximate number of milliseconds to run before returning. It will return this duration has elapsed. If 0 or Inf, then the function will continually process requests without returning unless an error occurs. If NA, performs a non-blocking run without waiting.

Details

In previous versions of httpuv (1.3.5 and below), even if a server created by startServer exists, no requests were serviced unless and until service was called.

This function simply calls run_now(), so if your application schedules any later callbacks, they will be invoked.

Examples

## Not run: 
while (TRUE) {
  service()
}

## End(Not run)

httpuv

HTTP and WebSocket Server Library

v1.6.1
GPL (>= 2) | file LICENSE
Authors
Joe Cheng [aut], Winston Chang [aut, cre], RStudio, PBC [cph], Hector Corrada Bravo [ctb], Jeroen Ooms [ctb], Andrzej Krzemienski [cph] (optional.hpp)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.