Skip to content

Instantly share code, notes, and snippets.

@samiuelson
Last active May 6, 2020 13:56
Show Gist options
  • Save samiuelson/2dd571d33badff3828b2526bd5774914 to your computer and use it in GitHub Desktop.
Save samiuelson/2dd571d33badff3828b2526bd5774914 to your computer and use it in GitHub Desktop.
private fun requestChannel() {
val channelData = mapOf("name" to "Live stream chat")
val request = QueryChannelRequest()
.withData(channelData)
.withMessages(20)
.withWatch()
channelController.query(request).enqueue {
if (it.isSuccess) {
_viewState.postValue(State.Messages(it.data().messages))
} else {
_viewState.postValue(State.Error("QueryChannelRequest error"))
Timber.e(it.error())
}
}
}
private fun subscribeToNewMessageEvent() {
chatClient.events().subscribe {
if (it is NewMessageEvent) {
_viewState.postValue(State.NewMessage(it.message))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment