Skip to content

Commit 4aa674e

Browse files
author
Devendra
committed
PAM changes for j2me/bb
1 parent d07f3a1 commit 4aa674e

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.pubnub.examples.me;
2+
3+
import java.util.Hashtable;
4+
5+
import javax.microedition.lcdui.ChoiceGroup;
6+
import javax.microedition.lcdui.Command;
7+
import javax.microedition.lcdui.CommandListener;
8+
import javax.microedition.lcdui.Display;
9+
import javax.microedition.lcdui.Displayable;
10+
import javax.microedition.lcdui.Form;
11+
import javax.microedition.lcdui.TextField;
12+
13+
import com.pubnub.api.Callback;
14+
import com.pubnub.api.Pubnub;
15+
import com.pubnub.api.PubnubError;
16+
17+
public class AuthKeyConfig extends PubnubCommand {
18+
19+
public AuthKeyConfig(Pubnub pubnub, Display display, Form menu) {
20+
super(pubnub, display, menu, "Set Auth Keys");
21+
}
22+
23+
protected void initForm() {
24+
final TextField txtAuthKey = new TextField("Auth Key : ", "", 255, TextField.ANY);
25+
26+
form = new Form("History");
27+
form.append(txtAuthKey);
28+
form.addCommand(new Command("Set Auth Key", Command.OK, 2));
29+
30+
form.setCommandListener(new CommandListener() {
31+
public void commandAction(Command arg0, Displayable arg1) {
32+
_pubnub.setAuthKey(txtAuthKey.getString());
33+
display.setCurrent(menu);
34+
}
35+
});
36+
37+
}
38+
39+
}

‎j2me/examples/PubnubExample/src/com/pubnub/examples/me/HereNow.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void successCallback(String channel, Object message) {
3030
notifyUser(message.toString());
3131
}
3232

33-
public void errorCallback(String channel, PubnubError message) {
33+
public void errorCallback(String channel, PubnubError error) {
3434
notifyUser(channel + " : " + error.toString());
3535
}
3636
});

‎j2me/examples/PubnubExample/src/com/pubnub/examples/me/PubnubMenu.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public Form getMenu() {
3131
final ToggleResumeOnReconnect toggleResumeOnReconnect;
3232
final Time time;
3333
final DisconnectAndResubscribe disconnectAndResubscribe;
34+
final AuthKeyConfig authKeyConfig;
3435
if (menu == null) {
3536
final Command exitCommand;
3637
final Command publishCommand;
@@ -45,6 +46,7 @@ public Form getMenu() {
4546
final Command detailedHistoryCommand;
4647
final Command disconnectAndResubscribeCommand;
4748
final Command toggleResumeOnReconnectCommand;
49+
final Command authKeyConfigCommand;
4850

4951
menu = new Form("Pubnub Demo Console");
5052
publish = new Publish(pubnub, display, menu);
@@ -56,6 +58,7 @@ public Form getMenu() {
5658
unsubscribe = new Unsubscribe(pubnub,display,menu);
5759
toggleResumeOnReconnect = new ToggleResumeOnReconnect(pubnub,display,menu);
5860
disconnectAndResubscribe = new DisconnectAndResubscribe(pubnub,display,menu);
61+
authKeyConfig = new AuthKeyConfig(pubnub,display,menu);
5962
time = new Time(pubnub,display,menu);
6063

6164

@@ -82,6 +85,9 @@ public Form getMenu() {
8285
menu.addCommand(hereNowCommand);
8386
exitCommand = new Command("Exit", Command.EXIT, 0);
8487
menu.addCommand(exitCommand);
88+
authKeyConfigCommand = new Command("Set Auth Key", Command.ITEM, 0);
89+
menu.addCommand(authKeyConfigCommand);
90+
8591
menu.setCommandListener(new CommandListener() {
8692

8793
public void commandAction(Command command, Displayable displayable) {
@@ -107,8 +113,11 @@ public void commandAction(Command command, Displayable displayable) {
107113
disconnectAndResubscribe.handler();
108114
} else if (command == toggleResumeOnReconnectCommand) {
109115
toggleResumeOnReconnect.handler();
116+
} else if (command == authKeyConfigCommand) {
117+
authKeyConfig.handler();
110118
}
111119

120+
112121
}
113122
});
114123
}

‎j2me/src1/com/pubnub/api/SubscribeWorker.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ void process(HttpRequest hreq) {
6868
log.verbose("Exhausted number of retries");
6969
hreq.getResponseHandler().handleTimeout(hreq);
7070
} else {
71-
hreq.getResponseHandler().handleError(hreq, PubnubError.PNERROBJ_CLIENT_TIMEOUT);
71+
if (excp != null && excp instanceof PubnubException && ((PubnubException) excp).getPubnubError() != null) {
72+
hreq.getResponseHandler().handleError(hreq, ((PubnubException) excp).getPubnubError());
73+
} else {
74+
hreq.getResponseHandler().handleError(hreq, PubnubError.getErrorObject(PubnubError.PNERROBJ_HTTP_ERROR, 1));
75+
}
7276
}
7377
return;
7478
}

0 commit comments

Comments
 (0)