Permalink
Browse files

CL-159: Presence Leave Event Not Occuring on Android with SSL Enabled

  • Loading branch information...
1 parent dcd5a04 commit 45ff68d59180c4142671d8fca634dcef85f4f438 @tanaji-kadam tanaji-kadam committed Nov 8, 2012
@@ -374,6 +374,7 @@ private void _subscribe(HashMap<String, Object> args) {
callback.disconnectCallback(channel);
isDisconnected = true;
subscriptions.remove(it);
+ leave(channel);
break;
}
}
@@ -391,6 +392,7 @@ private void _subscribe(HashMap<String, Object> args) {
callback.disconnectCallback(channel);
isDisconnected = true;
subscriptions.remove(it);
+ leave(channel);
break;
}
}
@@ -406,6 +408,7 @@ private void _subscribe(HashMap<String, Object> args) {
if (it.connected && it.first) {
subscriptions.remove(it);
callback.disconnectCallback(channel);
+ leave(channel);
} else {
subscriptions.remove(it);
callback.errorCallback(channel,
@@ -662,6 +665,33 @@ public JSONArray here_now(HashMap<String, Object> args) {
return _request(url, channel);
}
+ /**
+ *
+ */
+ public JSONArray leave(String channel) {
+ if (channel == null || channel.equals("")) {
+ JSONArray jsono = new JSONArray();
+ try {
+ jsono.put(0);
+ jsono.put("Missing Channel");
+ } catch (Exception jsone) {
+ }
+ return jsono;
+ }
+
+ // Build URL
+ List<String> url = new ArrayList<String>();
+ url.add("v2");
+ url.add("presence");
+ url.add("sub_key");
+ url.add(this.SUBSCRIBE_KEY);
+ url.add("channel");
+ url.add(channel);
+ url.add("leave");
+ // Return JSONArray
+ return _request(url, channel);
+
+ }
/**
* Time
@@ -737,6 +767,10 @@ private JSONArray _request(List<String> url_components, String channel) {
if (_callFor.equalsIgnoreCase("v2")) {
_callFor = url_components.get(1);
+ if(url_components.size()>=6 && url_components.get(6).equals("leave"))
+ {
+ _callFor="leave";
+ }
}
url.append(this.ORIGIN);
@@ -764,6 +798,9 @@ private JSONArray _request(List<String> url_components, String channel) {
if (_callFor.equalsIgnoreCase("subscribe")) {
url.append("/").append("?uuid=" + UUIDs);
}
+ if (_callFor.equalsIgnoreCase("leave")) {
+ url.append("?uuid=" + UUIDs);
+ }
try {
PubnubHttpRequest request = new PubnubHttpRequest(url.toString(),
@@ -801,7 +838,7 @@ private JSONArray _request(List<String> url_components, String channel) {
return jsono;
}
- if (_callFor.equalsIgnoreCase("presence")) {
+ if (_callFor.equalsIgnoreCase("presence") || _callFor.equalsIgnoreCase("leave")) {
try {
JSONArray arr = new JSONArray();
@@ -13,6 +13,7 @@
import com.sample.pubnubunittest.unittest.CL_155;
import com.sample.pubnubunittest.unittest.CL_165;
import com.sample.pubnubunittest.unittest.CL_216;
+import com.sample.pubnubunittest.unittest.CL_259;
public class ItemDetailFragment extends Fragment {
@@ -81,6 +82,14 @@ protected Boolean doInBackground(String... params) {
CL_165 cl165= new CL_165();
cl165.RunUnitTest(handler);
break;
+ case 3:
+ CL_216 cl216= new CL_216();
+ cl216.RunUnitTest(handler);
+ break;
+ case 4:
+ CL_259 cl259= new CL_259();
+ cl259.RunUnitTest(handler);
+ break;
default:
break;
}
@@ -30,6 +30,7 @@ public String toString() {
addItem(new MenuItem("1", "CL-155"));
addItem(new MenuItem("2", "CL-165"));
addItem(new MenuItem("3", "CL-216"));
+ addItem(new MenuItem("4", "CL-259"));
}
@@ -374,6 +374,7 @@ private void _subscribe(HashMap<String, Object> args) {
callback.disconnectCallback(channel);
isDisconnected = true;
subscriptions.remove(it);
+ leave(channel);
break;
}
}
@@ -391,6 +392,7 @@ private void _subscribe(HashMap<String, Object> args) {
callback.disconnectCallback(channel);
isDisconnected = true;
subscriptions.remove(it);
+ leave(channel);
break;
}
}
@@ -406,6 +408,7 @@ private void _subscribe(HashMap<String, Object> args) {
if (it.connected && it.first) {
subscriptions.remove(it);
callback.disconnectCallback(channel);
+ leave(channel);
} else {
subscriptions.remove(it);
callback.errorCallback(channel,
@@ -662,6 +665,31 @@ public JSONArray here_now(HashMap<String, Object> args) {
return _request(url, channel);
}
+
+ public JSONArray leave(String channel) {
+ if (channel == null || channel.equals("")) {
+ JSONArray jsono = new JSONArray();
+ try {
+ jsono.put(0);
+ jsono.put("Missing Channel");
+ } catch (Exception jsone) {
+ }
+ return jsono;
+ }
+
+ // Build URL
+ List<String> url = new ArrayList<String>();
+ url.add("v2");
+ url.add("presence");
+ url.add("sub_key");
+ url.add(this.SUBSCRIBE_KEY);
+ url.add("channel");
+ url.add(channel);
+ url.add("leave");
+ // Return JSONArray
+ return _request(url, channel);
+
+ }
/**
* Time
@@ -737,6 +765,10 @@ private JSONArray _request(List<String> url_components, String channel) {
if (_callFor.equalsIgnoreCase("v2")) {
_callFor = url_components.get(1);
+ if(url_components.size()>=6 && url_components.get(6).equals("leave"))
+ {
+ _callFor="leave";
+ }
}
url.append(this.ORIGIN);
@@ -764,6 +796,9 @@ private JSONArray _request(List<String> url_components, String channel) {
if (_callFor.equalsIgnoreCase("subscribe")) {
url.append("/").append("?uuid=" + UUIDs);
}
+ if (_callFor.equalsIgnoreCase("leave")) {
+ url.append("?uuid=" + UUIDs);
+ }
try {
PubnubHttpRequest request = new PubnubHttpRequest(url.toString(),
@@ -801,7 +836,7 @@ private JSONArray _request(List<String> url_components, String channel) {
return jsono;
}
- if (_callFor.equalsIgnoreCase("presence")) {
+ if (_callFor.equalsIgnoreCase("presence") || _callFor.equalsIgnoreCase("leave")) {
try {
JSONArray arr = new JSONArray();
Oops, something went wrong.

0 comments on commit 45ff68d

Please sign in to comment.