Skip to content

Commit

Permalink
PAM changes for j2me/bb
Browse files Browse the repository at this point in the history
  • Loading branch information
Devendra committed Jul 9, 2013
1 parent d07f3a1 commit 4aa674e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.pubnub.examples.me;

import java.util.Hashtable;

import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

import com.pubnub.api.Callback;
import com.pubnub.api.Pubnub;
import com.pubnub.api.PubnubError;

public class AuthKeyConfig extends PubnubCommand {

public AuthKeyConfig(Pubnub pubnub, Display display, Form menu) {
super(pubnub, display, menu, "Set Auth Keys");
}

protected void initForm() {
final TextField txtAuthKey = new TextField("Auth Key : ", "", 255, TextField.ANY);

form = new Form("History");
form.append(txtAuthKey);
form.addCommand(new Command("Set Auth Key", Command.OK, 2));

form.setCommandListener(new CommandListener() {
public void commandAction(Command arg0, Displayable arg1) {
_pubnub.setAuthKey(txtAuthKey.getString());
display.setCurrent(menu);
}
});

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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 @@ -31,6 +31,7 @@ public Form getMenu() {
final ToggleResumeOnReconnect toggleResumeOnReconnect;
final Time time;
final DisconnectAndResubscribe disconnectAndResubscribe;
final AuthKeyConfig authKeyConfig;
if (menu == null) {
final Command exitCommand;
final Command publishCommand;
Expand All @@ -45,6 +46,7 @@ public Form getMenu() {
final Command detailedHistoryCommand;
final Command disconnectAndResubscribeCommand;
final Command toggleResumeOnReconnectCommand;
final Command authKeyConfigCommand;

menu = new Form("Pubnub Demo Console");
publish = new Publish(pubnub, display, menu);
Expand All @@ -56,6 +58,7 @@ public Form getMenu() {
unsubscribe = new Unsubscribe(pubnub,display,menu);
toggleResumeOnReconnect = new ToggleResumeOnReconnect(pubnub,display,menu);
disconnectAndResubscribe = new DisconnectAndResubscribe(pubnub,display,menu);
authKeyConfig = new AuthKeyConfig(pubnub,display,menu);
time = new Time(pubnub,display,menu);


Expand All @@ -82,6 +85,9 @@ public Form getMenu() {
menu.addCommand(hereNowCommand);
exitCommand = new Command("Exit", Command.EXIT, 0);
menu.addCommand(exitCommand);
authKeyConfigCommand = new Command("Set Auth Key", Command.ITEM, 0);
menu.addCommand(authKeyConfigCommand);

menu.setCommandListener(new CommandListener() {

public void commandAction(Command command, Displayable displayable) {
Expand All @@ -107,8 +113,11 @@ public void commandAction(Command command, Displayable displayable) {
disconnectAndResubscribe.handler();
} else if (command == toggleResumeOnReconnectCommand) {
toggleResumeOnReconnect.handler();
} else if (command == authKeyConfigCommand) {
authKeyConfig.handler();
}


}
});
}
Expand Down
6 changes: 5 additions & 1 deletion j2me/src1/com/pubnub/api/SubscribeWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ void process(HttpRequest hreq) {
log.verbose("Exhausted number of retries");
hreq.getResponseHandler().handleTimeout(hreq);
} else {
hreq.getResponseHandler().handleError(hreq, PubnubError.PNERROBJ_CLIENT_TIMEOUT);
if (excp != null && excp instanceof PubnubException && ((PubnubException) excp).getPubnubError() != null) {
hreq.getResponseHandler().handleError(hreq, ((PubnubException) excp).getPubnubError());
} else {
hreq.getResponseHandler().handleError(hreq, PubnubError.getErrorObject(PubnubError.PNERROBJ_HTTP_ERROR, 1));
}
}
return;
}
Expand Down

0 comments on commit 4aa674e

Please sign in to comment.