Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
bfe48550
Commit
bfe48550
authored
Jul 23, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the temporary status on reconnection
parent
e7f17783
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
AppLifecycleObserver.kt
...main/java/chat/rocket/android/app/AppLifecycleObserver.kt
+4
-10
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+1
-1
ConnectionManager.kt
...ocket/android/server/infraestructure/ConnectionManager.kt
+19
-0
No files found.
app/src/main/java/chat/rocket/android/app/AppLifecycleObserver.kt
View file @
bfe48550
...
@@ -5,6 +5,7 @@ import androidx.lifecycle.LifecycleObserver
...
@@ -5,6 +5,7 @@ import androidx.lifecycle.LifecycleObserver
import
androidx.lifecycle.OnLifecycleEvent
import
androidx.lifecycle.OnLifecycleEvent
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.UserStatus
import
chat.rocket.common.model.UserStatus
...
@@ -15,8 +16,7 @@ import javax.inject.Inject
...
@@ -15,8 +16,7 @@ import javax.inject.Inject
class
AppLifecycleObserver
@Inject
constructor
(
class
AppLifecycleObserver
@Inject
constructor
(
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
factory
:
RocketChatClientFactory
,
private
val
factory
:
ConnectionManagerFactory
private
val
getAccountInteractor
:
GetAccountInteractor
)
:
LifecycleObserver
{
)
:
LifecycleObserver
{
@OnLifecycleEvent
(
Lifecycle
.
Event
.
ON_START
)
@OnLifecycleEvent
(
Lifecycle
.
Event
.
ON_START
)
...
@@ -31,14 +31,8 @@ class AppLifecycleObserver @Inject constructor(
...
@@ -31,14 +31,8 @@ class AppLifecycleObserver @Inject constructor(
private
fun
changeTemporaryStatus
(
userStatus
:
UserStatus
)
{
private
fun
changeTemporaryStatus
(
userStatus
:
UserStatus
)
{
launch
{
launch
{
val
currentServer
=
serverInteractor
.
get
()
serverInteractor
.
get
()
?.
let
{
currentServer
->
val
account
=
currentServer
?.
let
{
getAccountInteractor
.
get
(
currentServer
)
}
factory
.
create
(
currentServer
).
setTemporaryStatus
(
userStatus
)
val
client
=
account
?.
let
{
factory
.
create
(
currentServer
)
}
try
{
client
?.
setTemporaryStatus
(
userStatus
)
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
e
(
exception
)
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
bfe48550
...
@@ -176,7 +176,7 @@ class MainPresenter @Inject constructor(
...
@@ -176,7 +176,7 @@ class MainPresenter @Inject constructor(
fun
changeDefaultStatus
(
userStatus
:
UserStatus
)
{
fun
changeDefaultStatus
(
userStatus
:
UserStatus
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
client
.
setDefaultStatus
(
userStatus
)
manager
.
setDefaultStatus
(
userStatus
)
view
.
showUserStatus
(
userStatus
)
view
.
showUserStatus
(
userStatus
)
}
catch
(
ex
:
RocketChatException
)
{
}
catch
(
ex
:
RocketChatException
)
{
ex
.
message
?.
let
{
ex
.
message
?.
let
{
...
...
app/src/main/java/chat/rocket/android/server/infraestructure/ConnectionManager.kt
View file @
bfe48550
...
@@ -5,7 +5,10 @@ import chat.rocket.android.db.DatabaseManager
...
@@ -5,7 +5,10 @@ import chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.common.model.BaseRoom
import
chat.rocket.common.model.BaseRoom
import
chat.rocket.common.model.User
import
chat.rocket.common.model.User
import
chat.rocket.common.model.UserStatus
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.realtime.setDefaultStatus
import
chat.rocket.core.internal.realtime.setTemporaryStatus
import
chat.rocket.core.internal.realtime.socket.connect
import
chat.rocket.core.internal.realtime.socket.connect
import
chat.rocket.core.internal.realtime.socket.disconnect
import
chat.rocket.core.internal.realtime.socket.disconnect
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.internal.realtime.socket.model.State
...
@@ -49,6 +52,7 @@ class ConnectionManager(
...
@@ -49,6 +52,7 @@ class ConnectionManager(
private
var
roomsId
:
String
?
=
null
private
var
roomsId
:
String
?
=
null
private
var
userDataId
:
String
?
=
null
private
var
userDataId
:
String
?
=
null
private
var
activeUserId
:
String
?
=
null
private
var
activeUserId
:
String
?
=
null
private
var
temporaryStatus
:
UserStatus
?
=
null
private
val
activeUsersContext
=
newSingleThreadContext
(
"activeUsersContext"
)
private
val
activeUsersContext
=
newSingleThreadContext
(
"activeUsersContext"
)
private
val
roomsContext
=
newSingleThreadContext
(
"roomsContext"
)
private
val
roomsContext
=
newSingleThreadContext
(
"roomsContext"
)
...
@@ -90,6 +94,10 @@ class ConnectionManager(
...
@@ -90,6 +94,10 @@ class ConnectionManager(
}
}
resubscribeRooms
()
resubscribeRooms
()
temporaryStatus
?.
let
{
status
->
client
.
setTemporaryStatus
(
status
)
}
}
}
is
State
.
Waiting
->
{
is
State
.
Waiting
->
{
Timber
.
d
(
"Connection in: ${status.seconds}"
)
Timber
.
d
(
"Connection in: ${status.seconds}"
)
...
@@ -176,6 +184,16 @@ class ConnectionManager(
...
@@ -176,6 +184,16 @@ class ConnectionManager(
}
}
}
}
fun
setDefaultStatus
(
userStatus
:
UserStatus
)
{
temporaryStatus
=
null
client
.
setDefaultStatus
(
userStatus
)
}
fun
setTemporaryStatus
(
userStatus
:
UserStatus
)
{
temporaryStatus
=
userStatus
client
.
setTemporaryStatus
(
userStatus
)
}
private
fun
resubscribeRooms
()
{
private
fun
resubscribeRooms
()
{
roomMessagesChannels
.
toList
().
map
{
(
roomId
,
channel
)
->
roomMessagesChannels
.
toList
().
map
{
(
roomId
,
channel
)
->
client
.
subscribeRoomMessages
(
roomId
)
{
_
,
id
->
client
.
subscribeRoomMessages
(
roomId
)
{
_
,
id
->
...
@@ -190,6 +208,7 @@ class ConnectionManager(
...
@@ -190,6 +208,7 @@ class ConnectionManager(
client
.
removeStateChannel
(
statusChannel
)
client
.
removeStateChannel
(
statusChannel
)
client
.
disconnect
()
client
.
disconnect
()
connectJob
?.
cancel
()
connectJob
?.
cancel
()
temporaryStatus
=
null
}
}
fun
addStatusChannel
(
channel
:
Channel
<
State
>)
=
statusChannelList
.
add
(
channel
)
fun
addStatusChannel
(
channel
:
Channel
<
State
>)
=
statusChannelList
.
add
(
channel
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment