Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for server-sent events #481

Open
hadley opened this issue Jun 27, 2024 · 0 comments
Open

Add support for server-sent events #481

hadley opened this issue Jun 27, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@hadley
Copy link
Member

hadley commented Jun 27, 2024

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent%5Fevents/Using%5Fserver-sent%5Fevents#event_stream_format

Maybe req_perform_sse()? And then have some way to register functions for each event?

cutpoint <- function(bytes) {
  nl <- which(bytes == charToRaw("\n"))
  nl[nl %in% (setdiff(nl, 1) - 1)]
}

parser <- function(bytes) {
  text <- rawToChar(bytes)
  events <- strsplit(text, "\n\n")[[1]]
  lines <- strsplit(text, "\n")
  ...
}

req |> 
  req_perform_stream(round = cutpoint, callback = parser)
@hadley hadley added the feature a feature request or enhancement label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant