Created
April 23, 2022 19:42
-
-
Save hiteshchopra11/4f85298955711e52df4bd6e016528f61 to your computer and use it in GitHub Desktop.
EventSourceListener
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 eventSourceListener = object : EventSourceListener() { | |
override fun onOpen(eventSource: EventSource, response: Response) { | |
super.onOpen(eventSource, response) | |
Log.d(MainActivity.TAG, "Connection Opened") | |
} | |
override fun onClosed(eventSource: EventSource) { | |
super.onClosed(eventSource) | |
Log.d(MainActivity.TAG, "Connection Closed") | |
} | |
override fun onEvent( | |
eventSource: EventSource, | |
id: String?, | |
type: String?, | |
data: String | |
) { | |
super.onEvent(eventSource, id, type, data) | |
Log.d(MainActivity.TAG, "On Event Received! Data -: $data") | |
} | |
override fun onFailure(eventSource: EventSource, t: Throwable?, response: Response?) { | |
super.onFailure(eventSource, t, response) | |
Log.d(MainActivity.TAG, "On Failure -: ${response?.body}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment