This repository was archived by the owner on Jun 7, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
app/src/main/java/chat/rocket/android/chatroom Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import chat.rocket.common.model.UserStatus
4747import chat.rocket.common.model.roomTypeOf
4848import chat.rocket.common.util.ifNull
4949import chat.rocket.core.internal.realtime.setTypingStatus
50+ import chat.rocket.core.internal.realtime.socket.connect
5051import chat.rocket.core.internal.realtime.socket.model.State
5152import chat.rocket.core.internal.realtime.subscribeRoomMessages
5253import chat.rocket.core.internal.realtime.subscribeTypingStatus
@@ -356,6 +357,9 @@ class ChatRoomPresenter @Inject constructor(
356357 launchUI(strategy) {
357358 try {
358359 view.disableSendMessageButton()
360+ if (client.state is State .Disconnected || client.state is State .Waiting ){
361+ client.connect()
362+ }
359363 // ignore message for now, will receive it on the stream
360364 if (messageId == null ) {
361365 val id = UUID .randomUUID().toString()
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import chat.rocket.android.server.domain.GetAccountsInteractor
77import chat.rocket.android.server.infrastructure.ConnectionManagerFactory
88import chat.rocket.android.server.infrastructure.DatabaseMessageMapper
99import chat.rocket.android.server.infrastructure.DatabaseMessagesRepository
10+ import chat.rocket.core.internal.realtime.socket.connect
1011import chat.rocket.core.internal.rest.sendMessage
1112import chat.rocket.core.model.Message
1213import dagger.android.AndroidInjection
@@ -15,6 +16,8 @@ import kotlinx.coroutines.GlobalScope
1516import kotlinx.coroutines.launch
1617import timber.log.Timber
1718import javax.inject.Inject
19+ import chat.rocket.core.internal.realtime.socket.model.State
20+
1821
1922class MessageService : JobService () {
2023 @Inject
@@ -53,6 +56,9 @@ class MessageService : JobService() {
5356 val client = factory.create(serverUrl)?.client
5457 temporaryMessages.forEach { message ->
5558 try {
59+ if (client.state is State .Disconnected || client.state is State .Waiting ){
60+ client.connect()
61+ }
5662 client?.sendMessage(
5763 message = message.message,
5864 messageId = message.id,
@@ -88,4 +94,4 @@ class MessageService : JobService() {
8894 companion object {
8995 const val RETRY_SEND_MESSAGE_ID = 1
9096 }
91- }
97+ }
You can’t perform that action at this time.
0 commit comments