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
2a77ce1f
Commit
2a77ce1f
authored
Dec 11, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Plain Diff
FIX #74 Merge branch 'fix_issue_dup_connect' into develop
parents
a0af78fd
17a940d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
26 deletions
+15
-26
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+15
-26
No files found.
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
2a77ce1f
...
...
@@ -47,12 +47,12 @@ public class RocketChatService extends Service {
private
void
refreshServerConfigState
()
{
realmHelper
.
executeTransaction
(
realm
->
{
RealmResults
<
ServerConfig
>
configs
=
realm
.
where
(
ServerConfig
.
class
).
findAll
();
RealmResults
<
ServerConfig
>
configs
=
realm
.
where
(
ServerConfig
.
class
)
.
notEqualTo
(
"state"
,
ServerConfig
.
STATE_READY
)
.
findAll
();
for
(
ServerConfig
config:
configs
)
{
if
(
config
.
getState
()
!=
ServerConfig
.
STATE_READY
)
{
config
.
setState
(
ServerConfig
.
STATE_READY
);
}
}
return
null
;
}).
continueWith
(
new
LogcatIfError
());;
}
...
...
@@ -100,39 +100,28 @@ public class RocketChatService extends Service {
}
ServerConfig
config
=
configList
.
get
(
0
);
createWebSocketThread
(
config
).
onSuccess
(
task
->
{
final
String
serverConfigId
=
config
.
getServerConfigId
();
ServerConfig
.
updateState
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTING
)
.
onSuccessTask
(
task
->
createWebSocketThread
(
config
))
.
onSuccessTask
(
task
->
{
RocketChatWebSocketThread
thread
=
task
.
getResult
();
if
(
thread
!=
null
)
{
thread
.
keepalive
();
}
return
null
;
}
);
return
ServerConfig
.
updateState
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTED
)
;
}).
continueWith
(
new
LogcatIfError
()
);
}
private
Task
<
RocketChatWebSocketThread
>
createWebSocketThread
(
final
ServerConfig
config
)
{
final
String
serverConfigId
=
config
.
getServerConfigId
();
webSocketThreads
.
put
(
serverConfigId
,
null
);
return
ServerConfig
.
updateState
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTING
)
.
onSuccessTask
(
_task
->
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
config
))
.
onSuccessTask
(
task
->
ServerConfig
.
updateState
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTED
)
.
onSuccessTask
(
_task
->
task
))
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
config
)
.
onSuccessTask
(
task
->
{
webSocketThreads
.
put
(
serverConfigId
,
task
.
getResult
());
return
task
;
});
}
private
Task
<
RocketChatWebSocketThread
>
findOrCreateWebSocketThread
(
final
ServerConfig
config
)
{
final
String
serverConfigId
=
config
.
getServerConfigId
();
if
(
webSocketThreads
.
containsKey
(
serverConfigId
))
{
return
Task
.
forResult
(
webSocketThreads
.
get
(
serverConfigId
));
}
else
{
return
createWebSocketThread
(
config
);
}
}
@Override
public
void
onDestroy
()
{
if
(
connectionRequiredServerConfigObserver
!=
null
)
{
connectionRequiredServerConfigObserver
.
unsub
();
...
...
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