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
db0b3707
Commit
db0b3707
authored
Aug 16, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a ping rpc call that does not use bolts
parent
823f21ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
12 deletions
+11
-12
DDPClient.java
...-ddp/src/main/java/chat/rocket/android_ddp/DDPClient.java
+4
-3
DDPClientImpl.java
.../src/main/java/chat/rocket/android_ddp/DDPClientImpl.java
+5
-6
DDPClientWrapper.java
...c/main/java/chat/rocket/android/api/DDPClientWrapper.java
+2
-3
No files found.
android-ddp/src/main/java/chat/rocket/android_ddp/DDPClient.java
View file @
db0b3707
package
chat
.
rocket
.
android_ddp
;
package
chat
.
rocket
.
android_ddp
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
io.reactivex.Flowable
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
bolts.Task
;
import
bolts.Task
;
import
bolts.TaskCompletionSource
;
import
bolts.TaskCompletionSource
;
import
chat.rocket.android_ddp.rx.RxWebSocketCallback
;
import
chat.rocket.android_ddp.rx.RxWebSocketCallback
;
import
io.reactivex.Single
;
import
io.reactivex.Flowable
;
import
io.reactivex.Maybe
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
public
class
DDPClient
{
public
class
DDPClient
{
...
@@ -35,7 +36,7 @@ public class DDPClient {
...
@@ -35,7 +36,7 @@ public class DDPClient {
return
task
.
getTask
();
return
task
.
getTask
();
}
}
public
Flowabl
e
<
DDPClientCallback
.
Base
>
doPing
(
@Nullable
String
id
)
{
public
Mayb
e
<
DDPClientCallback
.
Base
>
doPing
(
@Nullable
String
id
)
{
return
impl
.
ping
(
id
);
return
impl
.
ping
(
id
);
}
}
...
...
android-ddp/src/main/java/chat/rocket/android_ddp/DDPClientImpl.java
View file @
db0b3707
...
@@ -17,7 +17,7 @@ import chat.rocket.android.log.RCLog;
...
@@ -17,7 +17,7 @@ import chat.rocket.android.log.RCLog;
import
chat.rocket.android_ddp.rx.RxWebSocket
;
import
chat.rocket.android_ddp.rx.RxWebSocket
;
import
chat.rocket.android_ddp.rx.RxWebSocketCallback
;
import
chat.rocket.android_ddp.rx.RxWebSocketCallback
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.
Singl
e
;
import
io.reactivex.
Mayb
e
;
import
io.reactivex.disposables.CompositeDisposable
;
import
io.reactivex.disposables.CompositeDisposable
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
...
@@ -107,7 +107,7 @@ public class DDPClientImpl {
...
@@ -107,7 +107,7 @@ public class DDPClientImpl {
}
}
}
}
public
Flowabl
e
<
DDPClientCallback
.
Base
>
ping
(
@Nullable
final
String
id
)
{
public
Mayb
e
<
DDPClientCallback
.
Base
>
ping
(
@Nullable
final
String
id
)
{
final
boolean
requested
=
(
TextUtils
.
isEmpty
(
id
))
?
final
boolean
requested
=
(
TextUtils
.
isEmpty
(
id
))
?
sendMessage
(
"ping"
,
null
)
:
sendMessage
(
"ping"
,
null
)
:
...
@@ -115,7 +115,6 @@ public class DDPClientImpl {
...
@@ -115,7 +115,6 @@ public class DDPClientImpl {
if
(
requested
)
{
if
(
requested
)
{
return
flowable
.
filter
(
callback
->
callback
instanceof
RxWebSocketCallback
.
Message
)
return
flowable
.
filter
(
callback
->
callback
instanceof
RxWebSocketCallback
.
Message
)
// .timeout(8, TimeUnit.SECONDS)
.
map
(
callback
->
((
RxWebSocketCallback
.
Message
)
callback
).
responseBodyString
)
.
map
(
callback
->
((
RxWebSocketCallback
.
Message
)
callback
).
responseBodyString
)
.
map
(
DDPClientImpl:
:
toJson
)
.
map
(
DDPClientImpl:
:
toJson
)
.
filter
(
response
->
"pong"
.
equalsIgnoreCase
(
extractMsg
(
response
)))
.
filter
(
response
->
"pong"
.
equalsIgnoreCase
(
extractMsg
(
response
)))
...
@@ -133,15 +132,15 @@ public class DDPClientImpl {
...
@@ -133,15 +132,15 @@ public class DDPClientImpl {
if
(
id
.
equals
(
_id
))
{
if
(
id
.
equals
(
_id
))
{
return
new
DDPClientCallback
.
Ping
(
client
,
_id
);
return
new
DDPClientCallback
.
Ping
(
client
,
_id
);
}
else
{
}
else
{
return
new
DDPClientCallback
.
Ping
.
UnMatched
(
client
,
id
);
return
new
DDPClientCallback
.
Ping
.
UnMatched
(
client
,
_
id
);
}
}
}
}
}
}
// if we receive anything other than a pong throw an exception
// if we receive anything other than a pong throw an exception
throw
new
DDPClientCallback
.
RPC
.
Error
(
client
,
id
,
response
);
throw
new
DDPClientCallback
.
RPC
.
Error
(
client
,
id
,
response
);
});
})
.
firstElement
()
;
}
else
{
}
else
{
return
Flowabl
e
.
error
(
new
DDPClientCallback
.
Closed
(
client
));
return
Mayb
e
.
error
(
new
DDPClientCallback
.
Closed
(
client
));
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/api/DDPClientWrapper.java
View file @
db0b3707
...
@@ -6,7 +6,6 @@ import org.json.JSONArray;
...
@@ -6,7 +6,6 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.concurrent.TimeoutException
;
import
bolts.Task
;
import
bolts.Task
;
import
chat.rocket.android.helper.OkHttpHelper
;
import
chat.rocket.android.helper.OkHttpHelper
;
...
@@ -16,7 +15,7 @@ import chat.rocket.android_ddp.DDPClient;
...
@@ -16,7 +15,7 @@ import chat.rocket.android_ddp.DDPClient;
import
chat.rocket.android_ddp.DDPClientCallback
;
import
chat.rocket.android_ddp.DDPClientCallback
;
import
chat.rocket.android_ddp.DDPSubscription
;
import
chat.rocket.android_ddp.DDPSubscription
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.
Singl
e
;
import
io.reactivex.
Mayb
e
;
/**
/**
* DDP client wrapper.
* DDP client wrapper.
...
@@ -130,7 +129,7 @@ public class DDPClientWrapper {
...
@@ -130,7 +129,7 @@ public class DDPClientWrapper {
/**
/**
* check WebSocket connectivity with ping.
* check WebSocket connectivity with ping.
*/
*/
public
Flowabl
e
<
DDPClientCallback
.
Base
>
doPing
()
{
public
Mayb
e
<
DDPClientCallback
.
Base
>
doPing
()
{
final
String
pingId
=
UUID
.
randomUUID
().
toString
();
final
String
pingId
=
UUID
.
randomUUID
().
toString
();
RCLog
.
d
(
"ping[%s] >"
,
pingId
);
RCLog
.
d
(
"ping[%s] >"
,
pingId
);
return
ddpClient
.
doPing
(
pingId
);
return
ddpClient
.
doPing
(
pingId
);
...
...
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