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
5535e0ad
Commit
5535e0ad
authored
Nov 06, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep a single socket connected
parent
c85bbb84
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
10 deletions
+26
-10
DDPClient.java
...-ddp/src/main/java/chat/rocket/android_ddp/DDPClient.java
+12
-5
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+1
-1
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+5
-0
ConnectivityManagerApi.java
...a/chat/rocket/android/service/ConnectivityManagerApi.java
+2
-0
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+3
-3
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+3
-1
No files found.
android-ddp/src/main/java/chat/rocket/android_ddp/DDPClient.java
View file @
5535e0ad
...
...
@@ -3,19 +3,20 @@ package chat.rocket.android_ddp;
import
android.text.TextUtils
;
import
chat.rocket.android.log.RCLog
;
import
io.reactivex.Flowable
;
import
io.reactivex.Maybe
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.Nullable
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicReference
;
import
bolts.Task
;
import
bolts.TaskCompletionSource
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.android_ddp.rx.RxWebSocketCallback
;
import
io.reactivex.Flowable
;
import
io.reactivex.Maybe
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.Nullable
;
import
okhttp3.OkHttpClient
;
public
class
DDPClient
{
...
...
@@ -24,6 +25,7 @@ public class DDPClient {
private
static
volatile
DDPClient
singleton
;
private
static
OkHttpClient
client
;
private
final
DDPClientImpl
impl
;
private
final
AtomicReference
<
String
>
hostname
=
new
AtomicReference
<>();
public
static
void
initialize
(
OkHttpClient
okHttpClient
)
{
client
=
okHttpClient
;
...
...
@@ -47,6 +49,11 @@ public class DDPClient {
}
public
Task
<
DDPClientCallback
.
Connect
>
connect
(
String
url
,
String
session
)
{
String
oldHostname
=
hostname
.
get
();
hostname
.
set
(
url
);
if
(
oldHostname
!=
null
&&
!
url
.
equalsIgnoreCase
(
oldHostname
))
{
close
();
}
TaskCompletionSource
<
DDPClientCallback
.
Connect
>
task
=
new
TaskCompletionSource
<>();
impl
.
connect
(
task
,
url
,
session
);
return
task
.
getTask
();
...
...
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
5535e0ad
...
...
@@ -103,7 +103,7 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
}
if
(
assertServerRealmStoreExists
(
newHostname
))
{
updateHostname
(
newHostname
);
recreate
(
);
}
else
{
recoverFromHostnameError
();
}
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
5535e0ad
...
...
@@ -67,11 +67,16 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
protected
void
onResume
()
{
super
.
onResume
();
if
(
hostname
==
null
||
presenter
==
null
)
{
String
previousHostname
=
hostname
;
hostname
=
new
RocketChatCache
(
getApplicationContext
()).
getSelectedServerHostname
();
if
(
hostname
==
null
)
{
showAddServerScreen
();
}
else
{
onHostnameUpdated
();
if
(!
hostname
.
equalsIgnoreCase
(
previousHostname
))
{
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
resetConnectivityStateList
();
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
keepAliveServer
();
}
}
}
else
{
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
keepAliveServer
();
...
...
app/src/main/java/chat/rocket/android/service/ConnectivityManagerApi.java
View file @
5535e0ad
...
...
@@ -25,4 +25,6 @@ public interface ConnectivityManagerApi {
Observable
<
ServerConnectivity
>
getServerConnectivityAsObservable
();
int
getConnectivityState
(
@NonNull
String
hostname
);
void
resetConnectivityStateList
();
}
app/src/main/java/chat/rocket/android/service/RealmBasedConnectivityManager.java
View file @
5535e0ad
...
...
@@ -13,6 +13,7 @@ import java.util.Map;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.helper.RxHelper
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.core.models.ServerInfo
;
...
...
@@ -68,12 +69,11 @@ import rx.subjects.PublishSubject;
@DebugLog
@Override
public
void
ensureConnections
()
{
for
(
String
hostname
:
serverConnectivityList
.
keySet
())
{
String
hostname
=
new
RocketChatCache
(
appContext
).
getSelectedServerHostname
();
connectToServerIfNeeded
(
hostname
,
true
/* force connect */
)
.
subscribe
(
_val
->
{
},
RCLog:
:
e
);
}
}
@Override
public
void
addOrUpdateServer
(
String
hostname
,
@Nullable
String
name
,
boolean
insecure
)
{
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
5535e0ad
...
...
@@ -263,7 +263,9 @@ public class RocketChatWebSocketThread extends HandlerThread {
// handling WebSocket#onClose() callback.
task
.
getResult
().
client
.
getOnCloseCallback
().
onSuccess
(
_task
->
{
if
(
_task
.
getResult
().
code
!=
1000
)
{
reconnect
();
}
return
null
;
});
...
...
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