Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- socket.on(EVENT_NOTIFICATION_CHAT, { args ->
- var jsonObject = JSONObject(args[0].toString())
- var type: String = jsonObject.getString("type")
- when (type) {
- TYPE_CHAT_NEW_MESSAGE -> {
- var responseWrapper: SocketNotificationResponseWrapper<ChatMessage>
- = SocketNotificationResponseWrapper()
- try {
- responseWrapper = objectMapper.readValue(args[0].toString())
- } catch (throwable: IOException) {
- socketPublishSubject?.onError(throwable)
- throwable.printStackTrace()
- }
- responseWrapper.data?.let {
- roomStore.chatDao().storeChatMessage(it)
- chatSocketService.get().refreshMyChats()
- }
- }
- TYPE_CHAT_IS_SEEN -> {
- var responseWrapper: SocketNotificationResponseWrapper<ChatMessage>
- = SocketNotificationResponseWrapper()
- try {
- responseWrapper = objectMapper.readValue(args[0].toString())
- } catch (throwable: IOException) {
- socketPublishSubject?.onError(throwable)
- throwable.printStackTrace()
- }
- responseWrapper.data?.let {
- roomStore.chatDao().storeChatMessage(it)
- }
- }
- TYPE_CHAT_IS_TYPING -> {
- socketPublishSubject?.onNext(SocketEvent("Typing", args))
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement