Skip to content

Commit 3cf4e99

Browse files
committed
clean up documentation
1 parent 54c27a6 commit 3cf4e99

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

mkdocs/docs/server-sent-events.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
## About Server Sent Events
33
Server-Sent Events (SSE) is a server push technology enabling a client to receive automatic updates from a server via an HTTP connection, and describes how servers can initiate data transmission towards clients once an initial client connection has been established. They are commonly used to send message updates or continuous data streams to a browser client and designed to enhance native, cross-browser streaming through a JavaScript API called EventSource, through which a client requests a particular URL in order to receive an event stream. The EventSource API is standardized as part of [HTML Living Standard by the WHATWG](https://html.spec.whatwg.org/multipage/server-sent-events.html).
4-
The media type for SSE is ```text/event-stream```.
4+
The default media type for SSE is ```text/event-stream```.
55

66
## Consuming Server Sent Events With Unirest-Java
77
Unirest has two ways to consume a SSE web service; one async and one synchronous. Please be mindful that SSE is a persistent connection and unirest will keep the connection open as long as the server is willing and able. For this reason you may find the async method a better fit for most production systems.
88

99
### Async Call
1010
The following subscribes to wikipedia's SSE stream of recently changed pages. Maps each event into a POJO, and outputs the name of the changed page.
11-
Note that Unirest will return you a CompletableFuture<Void> which you can hold on to to monitor the process.
11+
Note that Unirest will return you a ```CompletableFuture<Void>``` which you can hold on to to monitor the process.
1212
```java
1313
var future = Unirest.sse("https://stream.wikimedia.org/v2/stream/recentchange")
1414
.connect(event -> {
@@ -24,7 +24,7 @@ The following subscribes to wikipedia's SSE stream of recently changed pages. Ma
2424
```java
2525
Unirest.sse("https://stream.wikimedia.org/v2/stream/recentchange")
2626
.connect()
27-
.map(e -> e.asObject(RecentChange.class))
28-
.forEach(r -> System.out.println("Changed Page: " + r.getTitle()));
27+
.map(event -> event.asObject(RecentChange.class))
28+
.forEach(change -> System.out.println("Changed Page: " + change.getTitle()));
2929

3030
```

unirest-bdd-tests/src/test/java/BehaviorTests/SseRealExamples.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public class SseRealExamples {
3838
void sync() {
3939
Unirest.sse("https://stream.wikimedia.org/v2/stream/recentchange")
4040
.connect()
41-
.map(e -> e.asObject(RecentChange.class))
42-
.forEach(r -> System.out.println("Changed Page: " + r.getTitle()));
41+
.map(event -> event.asObject(RecentChange.class))
42+
.forEach(change -> System.out.println("Changed Page: " + change.getTitle()));
4343
}
4444

4545
@Test

0 commit comments

Comments
 (0)