Support for the equivalent of javascript's `setInterval`

Abierto
#230 11 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
r
Área
backend

Línea de trabajo

Start by examining httpuv's WebSocket handling around the ws object and the server lifecycle, with the later-based example as the behavioral reference. Determine how a server-scheduled message API should work and ensure scheduled callbacks stop when the server is terminated; the issue does not name specific files or tests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Most of the usage I've seen of httpuv's websocket functionality seems to use a method where the client will send a message which is then handled by the server which then responds with its own message.

For a project I am working on, a simpler solution is to have everything originate from the server which then sends a message on a scheduled basis out to the clients, i.e. something similar to what is possible with javascript's setInterval.

I've been able to achieve something like this by having a function recursively call itself with later on the desired interval,

onWSOpen = function(ws) {
  interval = 2
  
  f = function() {
    msg = paste("Hello", Sys.time())
    ws$send(msg)
    later::later(f, interval)
  }
  
  f()
}

but this feels a bit hacky, and I'm currently stuck with the later calls persisting even after the server is terminated. I feel like I will be able to find a way of using the ws object and httpuv::listServers to include a halt condition, but again this feels super hacky.

Lenguaje dominante
C
Estrellas
252
Forks
87
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rstudio/httpuv

Todos los issues de rstudio/httpuv

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.