Last active
May 6, 2020 13:56
-
-
Save samiuelson/2dd571d33badff3828b2526bd5774914 to your computer and use it in GitHub Desktop.
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
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