Skip to contents

This functions converts Server-Sent Events to a R list. This a wrapper function for the lower level SSEparser R6 class. A single string can contain multiple SSEs.

Usage

parse_sse(event)

Arguments

event

A length 1 string containing a server sent event as specified in the HTML spec.

Value

An R list on which each element is an event

Examples

event <- "data: test\nevent: message\nid: 123\n\n"
parse_sse(event)
#> [[1]]
#> [[1]]$data
#> [1] "test"
#> 
#> [[1]]$event
#> [1] "message"
#> 
#> [[1]]$id
#> [1] "123"
#> 
#> 

with_comment <- "data: test\n: comment\nevent: example\n\n"
parse_sse(with_comment)
#> [[1]]
#> [[1]]$data
#> [1] "test"
#> 
#> [[1]]$event
#> [1] "example"
#> 
#>