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
b5b67f3f
Commit
b5b67f3f
authored
Dec 13, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX #84 call unsubscribe on subscription done if needed.
parent
5b35e0f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
DDPClientWraper.java
...rc/main/java/chat/rocket/android/api/DDPClientWraper.java
+4
-1
AbstractDDPDocEventSubscriber.java
...et/android/service/ddp/AbstractDDPDocEventSubscriber.java
+8
-1
No files found.
app/src/main/java/chat/rocket/android/api/DDPClientWraper.java
View file @
b5b67f3f
...
...
@@ -57,13 +57,16 @@ public class DDPClientWraper {
* Subscribe with DDP client.
*/
public
Task
<
DDPSubscription
.
Ready
>
subscribe
(
final
String
name
,
JSONArray
param
)
{
return
ddpClient
.
sub
(
UUID
.
randomUUID
().
toString
(),
name
,
param
);
final
String
subscriptionId
=
UUID
.
randomUUID
().
toString
();
RCLog
.
d
(
"sub:[%s]> %s(%s)"
,
subscriptionId
,
name
,
param
);
return
ddpClient
.
sub
(
subscriptionId
,
name
,
param
);
}
/**
* Unsubscribe with DDP client.
*/
public
Task
<
DDPSubscription
.
NoSub
>
unsubscribe
(
final
String
subscriptionId
)
{
RCLog
.
d
(
"unsub:[%s]>"
,
subscriptionId
);
return
ddpClient
.
unsub
(
subscriptionId
);
}
...
...
app/src/main/java/chat/rocket/android/service/ddp/AbstractDDPDocEventSubscriber.java
View file @
b5b67f3f
...
...
@@ -21,6 +21,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
protected
final
String
hostname
;
protected
final
RealmHelper
realmHelper
;
protected
final
DDPClientWraper
ddpClient
;
private
boolean
isUnsubscribed
;
private
String
subscriptionId
;
private
Subscription
rxSubscription
;
...
...
@@ -53,6 +54,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
protected
void
onUnregister
()
{}
@Override
public
final
void
register
()
{
isUnsubscribed
=
false
;
JSONArray
params
=
null
;
try
{
params
=
getSubscriptionParams
();
...
...
@@ -61,7 +63,11 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
ddpClient
.
subscribe
(
getSubscriptionName
(),
params
).
onSuccess
(
task
->
{
subscriptionId
=
task
.
getResult
().
id
;
if
(
isUnsubscribed
)
{
ddpClient
.
unsubscribe
(
task
.
getResult
().
id
).
continueWith
(
new
LogcatIfError
());
}
else
{
subscriptionId
=
task
.
getResult
().
id
;
}
return
null
;
}).
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
...
...
@@ -165,6 +171,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
@Override
public
final
void
unregister
()
{
isUnsubscribed
=
true
;
onUnregister
();
if
(
rxSubscription
!=
null
)
{
rxSubscription
.
unsubscribe
();
...
...
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