Created
April 23, 2022 19:55
-
-
Save hiteshchopra11/1c49f196bf42dd47f5c5e4f38e8abdc2 to your computer and use it in GitHub Desktop.
OkHttp Client and EventSourceFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val client = OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS) | |
.readTimeout(10, TimeUnit.MINUTES) | |
.writeTimeout(10, TimeUnit.MINUTES) | |
.build() | |
val request = Request.Builder() | |
.url("https://test-sse-backend.herokuapp.com/events") | |
.header("Accept", "application/json; q=0.5") | |
.addHeader("Accept", "text/event-stream") | |
.build() | |
EventSources.createFactory(client) | |
.newEventSource(request = request, listener = eventSourceListener) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment