Skip to content

Commit

Permalink
remove sleep from first attempt in subscribe thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Devendra committed Jul 9, 2013
1 parent f2730b7 commit 7c3a53f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.pubnub.examples.blackberry;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.container.MainScreen;

import com.pubnub.api.Pubnub;

public class AuthKeyConfig extends PubnubCommand {

public AuthKeyConfig(Pubnub pubnub) {
super(pubnub, "Auth Key Config");
}

protected void initScreen() {
final BasicEditField txtAuthKey = new BasicEditField("Auth Key : ", "", 256, BasicEditField.FILTER_DEFAULT);
screen = new MainScreen();
screen.add(txtAuthKey);

ButtonField btn = new ButtonField();
btn.setLabel("Set Auth Key");
screen.add(btn);

btn.setChangeListener(new FieldChangeListener() {

public void fieldChanged(Field field, int context) {

try {
_pubnub.setAuthKey(txtAuthKey.getText());
close();
} catch (Exception e) {

}
}});
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void successCallback(String channel, Object message) {
notifyUser(message.toString());
}

public void errorCallback(String channel, PubnubError message) {
public void errorCallback(String channel, PubnubError error) {
notifyUser(channel + " : " + error.toString());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void successCallback(String channel, Object message) {
notifyUser(message.toString());
}

public void errorCallback(String channel, PubnubError message) {
public void errorCallback(String channel, PubnubError error) {
notifyUser(channel + " : " + error.toString());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void successCallback(String channel, Object message) {
notifyUser(message.toString());
}

public void errorCallback(String channel, PubnubError message) {
public void errorCallback(String channel, PubnubError error) {
notifyUser(channel + " : " + error.toString());
}
});
Expand Down
13 changes: 9 additions & 4 deletions j2me/src1/com/pubnub/api/SubscribeWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ void process(HttpRequest hreq) {
HttpResponse hresp = null;
int currentRetryAttempt = (hreq.isDar())?1:maxRetries;
log.verbose("disconnectAndResubscribe is " + hreq.isDar());
boolean sleep = false;
while (!_die && currentRetryAttempt <= maxRetries) {
if (sleep) {
try {
Thread.sleep(retryInterval);
} catch (InterruptedException e) {
}
sleep = true;
}
try {
log.debug(hreq.getUrl());
hresp = httpclient.fetch(hreq.getUrl(), hreq.getHeaders());
Expand Down Expand Up @@ -56,10 +64,7 @@ void process(HttpRequest hreq) {
currentRetryAttempt++;
}

try {
Thread.sleep(retryInterval);
} catch (InterruptedException e) {
}

}
if (!_die) {
if (hresp == null) {
Expand Down

0 comments on commit 7c3a53f

Please sign in to comment.