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
Hide 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
import
androidx.lifecycle.OnLifecycleEvent
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.UserStatus
...
...
@@ -15,8 +16,7 @@ import javax.inject.Inject
class
AppLifecycleObserver
@Inject
constructor
(
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
factory
:
RocketChatClientFactory
,
private
val
getAccountInteractor
:
GetAccountInteractor
private
val
factory
:
ConnectionManagerFactory
)
:
LifecycleObserver
{
@OnLifecycleEvent
(
Lifecycle
.
Event
.
ON_START
)
...
...
@@ -31,14 +31,8 @@ class AppLifecycleObserver @Inject constructor(
private
fun
changeTemporaryStatus
(
userStatus
:
UserStatus
)
{
launch
{
val
currentServer
=
serverInteractor
.
get
()
val
account
=
currentServer
?.
let
{
getAccountInteractor
.
get
(
currentServer
)
}
val
client
=
account
?.
let
{
factory
.
create
(
currentServer
)
}
try
{
client
?.
setTemporaryStatus
(
userStatus
)
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
e
(
exception
)
serverInteractor
.
get
()
?.
let
{
currentServer
->
factory
.
create
(
currentServer
).
setTemporaryStatus
(
userStatus
)
}
}
}
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
bfe48550
...
...
@@ -176,7 +176,7 @@ class MainPresenter @Inject constructor(
fun
changeDefaultStatus
(
userStatus
:
UserStatus
)
{
launchUI
(
strategy
)
{
try
{
client
.
setDefaultStatus
(
userStatus
)
manager
.
setDefaultStatus
(
userStatus
)
view
.
showUserStatus
(
userStatus
)
}
catch
(
ex
:
RocketChatException
)
{
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
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.common.model.BaseRoom
import
chat.rocket.common.model.User
import
chat.rocket.common.model.UserStatus
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.disconnect
import
chat.rocket.core.internal.realtime.socket.model.State
...
...
@@ -49,6 +52,7 @@ class ConnectionManager(
private
var
roomsId
:
String
?
=
null
private
var
userDataId
:
String
?
=
null
private
var
activeUserId
:
String
?
=
null
private
var
temporaryStatus
:
UserStatus
?
=
null
private
val
activeUsersContext
=
newSingleThreadContext
(
"activeUsersContext"
)
private
val
roomsContext
=
newSingleThreadContext
(
"roomsContext"
)
...
...
@@ -90,6 +94,10 @@ class ConnectionManager(
}
resubscribeRooms
()
temporaryStatus
?.
let
{
status
->
client
.
setTemporaryStatus
(
status
)
}
}
is
State
.
Waiting
->
{
Timber
.
d
(
"Connection in: ${status.seconds}"
)
...
...
@@ -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
()
{
roomMessagesChannels
.
toList
().
map
{
(
roomId
,
channel
)
->
client
.
subscribeRoomMessages
(
roomId
)
{
_
,
id
->
...
...
@@ -190,6 +208,7 @@ class ConnectionManager(
client
.
removeStateChannel
(
statusChannel
)
client
.
disconnect
()
connectJob
?.
cancel
()
temporaryStatus
=
null
}
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