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
6fbbd3c1
Commit
6fbbd3c1
authored
Nov 10, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if server is a non connected state before continuing
parent
739efd88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+5
-4
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+1
-4
No files found.
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
6fbbd3c1
...
...
@@ -80,7 +80,7 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
@Override
public
Single
<
Boolean
>
disconnectFromServer
(
String
hostname
)
{
//called via binder.
return
Single
.
defer
(()
->
{
if
(!
threadCreate
dForHostname
(
hostname
))
{
if
(!
existsThrea
dForHostname
(
hostname
))
{
return
Single
.
just
(
true
);
}
...
...
@@ -104,8 +104,8 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
return
Single
.
defer
(()
->
{
webSocketThreadLock
.
acquire
();
int
connectivityState
=
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
getConnectivityState
(
hostname
);
boolean
is
Connected
=
connectivityState
=
=
ServerConnectivity
.
STATE_CONNECTED
;
if
(
currentWebSocketThread
!=
null
&&
threadCreatedForHostname
(
hostname
)
)
{
boolean
is
Disconnected
=
connectivityState
!
=
ServerConnectivity
.
STATE_CONNECTED
;
if
(
currentWebSocketThread
!=
null
&&
existsThreadForHostname
(
hostname
)
&&
!
isDisconnected
)
{
webSocketThreadLock
.
release
();
return
Single
.
just
(
currentWebSocketThread
);
}
...
...
@@ -114,6 +114,7 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
if
(
currentWebSocketThread
!=
null
)
{
return
currentWebSocketThread
.
terminate
()
.
doAfterTerminate
(()
->
currentWebSocketThread
=
null
)
.
doOnError
(
RCLog:
:
e
)
.
flatMap
(
terminated
->
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
hostname
)
...
...
@@ -144,7 +145,7 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
});
}
private
boolean
threadCreate
dForHostname
(
String
hostname
)
{
private
boolean
existsThrea
dForHostname
(
String
hostname
)
{
if
(
hostname
==
null
||
currentWebSocketThread
==
null
)
{
return
false
;
}
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
6fbbd3c1
...
...
@@ -320,10 +320,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
error
->
{
logErrorAndUnsubscribe
(
reconnectSubscription
,
error
);
connectivityManager
.
notifyConnectionLost
(
hostname
,
DDPClient
.
REASON_CLOSED_BY_USER
);
if
(
isAlive
())
{
new
Handler
(
getLooper
()).
post
(
this
::
unregisterListeners
);
}
DDPClient
.
REASON_NETWORK_ERROR
);
}
)
);
...
...
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