Permalink
Browse files

CL-216:User should be able to override sessionUUID during object

instantiation
  • Loading branch information...
1 parent 02d6a26 commit 42682baa590ca9e6763d2115b8ddc04a2ab0bb9b @tanaji-kadam tanaji-kadam committed Oct 16, 2012
@@ -56,6 +56,27 @@
private Hashtable<String, Object> connection = new Hashtable<String, Object>();
/**
+ *
+ * Prepare PubNub State.
+ *
+ * @param String
+ * Publish Key.
+ * @param String
+ * Subscribe Key.
+ * @param String
+ * Secret Key.
+ * @param String
+ * Cipher Key.
+ * @param boolean SSL Enabled.
+ *
+ * @param String uuid.
+ */
+ public Pubnub(String publish_key, String subscribe_key, String secret_key,
+ String cipher_key, boolean ssl_on,String uuid) {
+ this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on,uuid);
+ }
+
+ /**
* PubNub 3.2 with Presence
*
* Prepare PubNub State.
@@ -72,7 +93,7 @@
*/
public Pubnub(String publish_key, String subscribe_key, String secret_key,
String cipher_key, boolean ssl_on) {
- this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on);
+ this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on,uuid());
}
/**
@@ -90,7 +111,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
*/
public Pubnub(String publish_key, String subscribe_key, String secret_key,
boolean ssl_on) {
- this.init(publish_key, subscribe_key, secret_key, "", ssl_on);
+ this.init(publish_key, subscribe_key, secret_key, "", ssl_on,uuid());
}
/**
@@ -104,7 +125,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
* Subscribe Key.
*/
public Pubnub(String publish_key, String subscribe_key) {
- this.init(publish_key, subscribe_key, "", "", false);
+ this.init(publish_key, subscribe_key, "", "", false,uuid());
}
/**
@@ -120,7 +141,7 @@ public Pubnub(String publish_key, String subscribe_key) {
* Secret Key.
*/
public Pubnub(String publish_key, String subscribe_key, String secret_key) {
- this.init(publish_key, subscribe_key, secret_key, "", false);
+ this.init(publish_key, subscribe_key, secret_key, "", false,uuid());
}
/**
@@ -139,7 +160,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key) {
* @param boolean SSL Enabled.
*/
public void init(String publish_key, String subscribe_key,
- String secret_key, String cipher_key, boolean ssl_on) {
+ String secret_key, String cipher_key, boolean ssl_on,String uuid) {
this.PUBLISH_KEY = publish_key;
this.SUBSCRIBE_KEY = subscribe_key;
this.SECRET_KEY = secret_key;
@@ -152,7 +173,7 @@ public void init(String publish_key, String subscribe_key,
} else {
this.ORIGIN = "http://" + this.ORIGIN;
}
- UUIDs = uuid();
+ UUIDs = uuid;
}
/**
@@ -431,6 +452,7 @@ private void _subscribe(HashMap<String, Object> args) {
if (response.optString(1).length() > 0)
timetoken = response.optString(1);
+ boolean returnval = true;
for (int i = 0; messages.length() > i; i++) {
JSONObject message = messages.optJSONObject(i);
if (message != null) {
@@ -441,7 +463,9 @@ private void _subscribe(HashMap<String, Object> args) {
message = pc.decrypt(message);
}
if (callback != null)
- callback.subscribeCallback(channel, message);
+ {
+ returnval=callback.subscribeCallback(channel, message);
+ }
} else {
JSONArray arr = messages.optJSONArray(i);
@@ -453,7 +477,7 @@ private void _subscribe(HashMap<String, Object> args) {
;
}
if (callback != null)
- callback.subscribeCallback(channel, arr);
+ returnval=callback.subscribeCallback(channel, arr);
} else {
String msgs = messages.getString(0);
if (this.CIPHER_KEY.length() > 0) {
@@ -462,10 +486,15 @@ private void _subscribe(HashMap<String, Object> args) {
msgs = pc.decrypt(msgs);
}
if (callback != null)
- callback.subscribeCallback(channel, msgs);
+ returnval=callback.subscribeCallback(channel, msgs);
}
}
}
+
+ if(!returnval)
+ {
+ break;
+ }
} catch (Exception e) {
try {
Thread.sleep(1000);
@@ -12,6 +12,7 @@
import com.sample.pubnubunittest.unittest.CL_155;
import com.sample.pubnubunittest.unittest.CL_165;
+import com.sample.pubnubunittest.unittest.CL_216;
public class ItemDetailFragment extends Fragment {
@@ -29,6 +29,7 @@ public String toString() {
static {
addItem(new MenuItem("1", "CL-155"));
addItem(new MenuItem("2", "CL-165"));
+ addItem(new MenuItem("3", "CL-216"));
}
@@ -1,7 +1,5 @@
package com.sample.pubnubunittest.pubnub;
-
-
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -58,6 +56,27 @@
private Hashtable<String, Object> connection = new Hashtable<String, Object>();
/**
+ *
+ * Prepare PubNub State.
+ *
+ * @param String
+ * Publish Key.
+ * @param String
+ * Subscribe Key.
+ * @param String
+ * Secret Key.
+ * @param String
+ * Cipher Key.
+ * @param boolean SSL Enabled.
+ *
+ * @param String uuid.
+ */
+ public Pubnub(String publish_key, String subscribe_key, String secret_key,
+ String cipher_key, boolean ssl_on,String uuid) {
+ this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on,uuid);
+ }
+
+ /**
* PubNub 3.2 with Presence
*
* Prepare PubNub State.
@@ -74,7 +93,7 @@
*/
public Pubnub(String publish_key, String subscribe_key, String secret_key,
String cipher_key, boolean ssl_on) {
- this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on);
+ this.init(publish_key, subscribe_key, secret_key, cipher_key, ssl_on,uuid());
}
/**
@@ -92,7 +111,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
*/
public Pubnub(String publish_key, String subscribe_key, String secret_key,
boolean ssl_on) {
- this.init(publish_key, subscribe_key, secret_key, "", ssl_on);
+ this.init(publish_key, subscribe_key, secret_key, "", ssl_on,uuid());
}
/**
@@ -106,7 +125,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key,
* Subscribe Key.
*/
public Pubnub(String publish_key, String subscribe_key) {
- this.init(publish_key, subscribe_key, "", "", false);
+ this.init(publish_key, subscribe_key, "", "", false,uuid());
}
/**
@@ -122,7 +141,7 @@ public Pubnub(String publish_key, String subscribe_key) {
* Secret Key.
*/
public Pubnub(String publish_key, String subscribe_key, String secret_key) {
- this.init(publish_key, subscribe_key, secret_key, "", false);
+ this.init(publish_key, subscribe_key, secret_key, "", false,uuid());
}
/**
@@ -141,7 +160,7 @@ public Pubnub(String publish_key, String subscribe_key, String secret_key) {
* @param boolean SSL Enabled.
*/
public void init(String publish_key, String subscribe_key,
- String secret_key, String cipher_key, boolean ssl_on) {
+ String secret_key, String cipher_key, boolean ssl_on,String uuid) {
this.PUBLISH_KEY = publish_key;
this.SUBSCRIBE_KEY = subscribe_key;
this.SECRET_KEY = secret_key;
@@ -154,7 +173,7 @@ public void init(String publish_key, String subscribe_key,
} else {
this.ORIGIN = "http://" + this.ORIGIN;
}
- UUIDs = uuid();
+ UUIDs = uuid;
}
/**
@@ -433,7 +452,7 @@ private void _subscribe(HashMap<String, Object> args) {
if (response.optString(1).length() > 0)
timetoken = response.optString(1);
- boolean subResponce=true;
+ boolean returnval = true;
for (int i = 0; messages.length() > i; i++) {
JSONObject message = messages.optJSONObject(i);
if (message != null) {
@@ -444,8 +463,9 @@ private void _subscribe(HashMap<String, Object> args) {
message = pc.decrypt(message);
}
if (callback != null)
- subResponce=callback.subscribeCallback(channel, message);
-
+ {
+ returnval=callback.subscribeCallback(channel, message);
+ }
} else {
JSONArray arr = messages.optJSONArray(i);
@@ -457,8 +477,7 @@ private void _subscribe(HashMap<String, Object> args) {
;
}
if (callback != null)
- subResponce=callback.subscribeCallback(channel, arr);
-
+ returnval=callback.subscribeCallback(channel, arr);
} else {
String msgs = messages.getString(0);
if (this.CIPHER_KEY.length() > 0) {
@@ -467,12 +486,12 @@ private void _subscribe(HashMap<String, Object> args) {
msgs = pc.decrypt(msgs);
}
if (callback != null)
- subResponce=callback.subscribeCallback(channel, msgs);
-
+ returnval=callback.subscribeCallback(channel, msgs);
}
}
}
- if(!subResponce)
+
+ if(!returnval)
{
break;
}
Oops, something went wrong.

0 comments on commit 42682ba

Please sign in to comment.