Skip to content

Files

Latest commit

b93d7b4 · Jan 6, 2021

History

History
25 lines (20 loc) · 743 Bytes

README.md

File metadata and controls

25 lines (20 loc) · 743 Bytes

Event Stream Client for Server-Sent Events

Full implementation of a HTTP event stream client that listen for Server-Sent Events (SSE).
Requires Java 11 or higher, no other libraries are needed.

How to use:

HttpEventStreamClient client = new HttpEventStreamClient("https://sse.example.com", new EventStreamAdapter() {
			
	@Override
	public void onEvent(HttpEventStreamClient client, Event event) {
		System.out.println("RECEIVED EVENT: "+event.toString());
	}

	@Override
	public void onClose(HttpEventStreamClient client, HttpResponse<Void> response) {
		System.out.println("SSE Client closed");
	}

});
client.start().join();

References: