Skip to content

Commit 8004785

Browse files
author
geremy
committed
adding remaining java clients
1 parent d2fbd75 commit 8004785

454 files changed

Lines changed: 110256 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

blackberry/3.4/CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CHANGELOG
2+
3+
02-12-2013 - 89e2be5e5f0fa872fcdf617a6c9af9ce30ae7807
4+
. client is now fully asyncronous
5+
. added enhanced multiplexed subscribe support
6+
. better error handling added to example app
7+
. improved keep-alive handling
8+
. support for chunked responses

blackberry/3.4/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
2+
##### http://www.pubnub.com/account
3+
4+
## PubNub 3.4 Real-time Cloud Push API - BlackBerry
5+
6+
www.pubnub.com - PubNub Real-time Push Service in the Cloud.
7+
8+
Please reference the demo app! Detailed instruction on how to run can be found at: https://s3.amazonaws.com/pubnub/github/Pubnub%2520Blackberry%2520Example%2520App%2520Setup%2520Guide.doc
9+
10+
for an example of how to bring real-time asyncronously in your applications!
11+

blackberry/3.4/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
02-12-2013 - 89e2be5e5f0fa872fcdf617a6c9af9ce30ae7807
52.6 KB
Binary file not shown.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.pubnub.examples.blackberry;
2+
3+
import net.rim.device.api.ui.UiApplication;
4+
import net.rim.device.api.ui.component.Dialog;
5+
6+
import com.pubnub.api.Pubnub;
7+
8+
/**
9+
* This class extends the UiApplication class, providing a
10+
* graphical user interface.
11+
*/
12+
public class PubnubExample extends UiApplication
13+
{
14+
/**
15+
* Entry point for application
16+
* @param args Command line arguments (not used)
17+
*/
18+
public static void main(String[] args)
19+
{
20+
21+
// Create a new instance of the application and make the currently
22+
// running thread the application's event dispatch thread.
23+
PubnubExample theApp = new PubnubExample();
24+
theApp.enterEventDispatcher();
25+
}
26+
27+
28+
/**
29+
* Creates a new PubnubExample object
30+
*/
31+
public PubnubExample()
32+
{
33+
// Push a screen onto the UI stack for rendering.
34+
pushScreen(new PubnubExampleScreen());
35+
}
36+
37+
/**
38+
* Presents a dialog to the user with a given message
39+
*
40+
* @param message
41+
* The text to display
42+
*/
43+
public static void alertDialog(final String message) {
44+
UiApplication.getUiApplication().invokeLater(new Runnable() {
45+
public void run() {
46+
Dialog.alert(message);
47+
}
48+
});
49+
}
50+
}
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
package com.pubnub.examples.blackberry;
2+
3+
import java.util.Hashtable;
4+
5+
import net.rim.device.api.command.Command;
6+
import net.rim.device.api.command.CommandHandler;
7+
import net.rim.device.api.command.ReadOnlyCommandMetadata;
8+
import net.rim.device.api.ui.MenuItem;
9+
import net.rim.device.api.ui.component.LabelField;
10+
import net.rim.device.api.ui.container.MainScreen;
11+
import net.rim.device.api.util.StringProvider;
12+
13+
import com.pubnub.api.Callback;
14+
import com.pubnub.api.Pubnub;
15+
import com.pubnub.api.PubnubException;
16+
17+
/**
18+
* A class extending the MainScreen class, which provides default standard
19+
* behavior for BlackBerry GUI applications.
20+
*/
21+
public final class PubnubExampleScreen extends MainScreen
22+
{
23+
String channel = "hello_world";
24+
String[] channels = { "hello_world1", "hello_world2", "hello_world3",
25+
"hello_world4" };
26+
Pubnub _pubnub = new Pubnub("demo","demo","demo", false);
27+
/**
28+
* Creates a new PubnubExampleScreen object
29+
*/
30+
public PubnubExampleScreen()
31+
{
32+
// Set the displayed title of the screen
33+
setTitle("PubnubExample");
34+
add(new LabelField("Please select an item from the menu"));
35+
add(new LabelField("Subscribe will listen on following channels: "));
36+
add(new LabelField("hello_world1, hello_world2, hello_world3, hello_world4"));
37+
add(new LabelField("Publish, history, detailedHistory, hereNow, Presence use hello_world"));
38+
39+
40+
addMenuItem(new TimeMenuItem());
41+
addMenuItem(new PublishMenuItem());
42+
addMenuItem(new HereNowMenuItem());
43+
addMenuItem(new HistoryMenuItem());
44+
addMenuItem(new DetailedHistoryMenuItem());
45+
addMenuItem(new SubscribeMenuItem());
46+
addMenuItem(new UnsubscribeMenuItem());
47+
addMenuItem(new PresenceMenuItem());
48+
addMenuItem(new ToggleRoRMenuItem());
49+
addMenuItem(new DisconnectAndResubMenuItem());
50+
}
51+
52+
53+
private class TimeMenuItem extends MenuItem
54+
{
55+
public TimeMenuItem()
56+
{
57+
super(new StringProvider("Time"), 0x230010, 0);
58+
this.setCommand(new Command(new CommandHandler()
59+
{
60+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
61+
{ _pubnub.time(new Callback() {
62+
public void successCallback(String channel, Object message) {
63+
PubnubExample.alertDialog(message.toString());
64+
}
65+
66+
public void errorCallback(String channel, Object message) {
67+
PubnubExample.alertDialog(message.toString());
68+
}
69+
});
70+
}
71+
}));
72+
}
73+
}
74+
private class DisconnectAndResubMenuItem extends MenuItem
75+
{
76+
public DisconnectAndResubMenuItem()
77+
{
78+
super(new StringProvider("Disconnect and Resubscribe"), 0x230010, 0);
79+
this.setCommand(new Command(new CommandHandler()
80+
{
81+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
82+
{ _pubnub.disconnectAndResubscribe();
83+
}
84+
}));
85+
}
86+
}
87+
private class ToggleRoRMenuItem extends MenuItem
88+
{
89+
public ToggleRoRMenuItem()
90+
{
91+
super(new StringProvider("Toggle Resume on Reconnect"), 0x230010, 0);
92+
this.setCommand(new Command(new CommandHandler()
93+
{
94+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
95+
{ _pubnub.setResumeOnReconnect(_pubnub.isResumeOnReconnect()?false:true);
96+
}
97+
}));
98+
}
99+
}
100+
private class PublishMenuItem extends MenuItem
101+
{
102+
public PublishMenuItem()
103+
{
104+
super(new StringProvider("Publish"), 0x230010, 0);
105+
this.setCommand(new Command(new CommandHandler()
106+
{
107+
public void execute(ReadOnlyCommandMetadata metadata, Object context) {
108+
109+
_pubnub.publish(channel, "Blackberry says hello world", new Callback() {
110+
public void successCallback(String channel, Object message) {
111+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
112+
}
113+
114+
public void errorCallback(String channel, Object message) {
115+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
116+
}
117+
});
118+
119+
}}));
120+
}
121+
}
122+
private class HereNowMenuItem extends MenuItem
123+
{
124+
public HereNowMenuItem()
125+
{
126+
super(new StringProvider("HereNow"), 0x230010, 0);
127+
this.setCommand(new Command(new CommandHandler()
128+
{
129+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
130+
{
131+
_pubnub.hereNow(channel, new Callback() {
132+
public void successCallback(String channel, Object message) {
133+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
134+
}
135+
136+
public void errorCallback(String channel, Object message) {
137+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
138+
}
139+
});
140+
}
141+
}));
142+
}
143+
}
144+
private class HistoryMenuItem extends MenuItem
145+
{
146+
public HistoryMenuItem()
147+
{
148+
super(new StringProvider("History"), 0x230010, 0);
149+
this.setCommand(new Command(new CommandHandler()
150+
{
151+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
152+
{
153+
_pubnub.history(channel, 1, new Callback() {
154+
public void successCallback(String channel, Object message) {
155+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
156+
}
157+
158+
public void errorCallback(String channel, Object message) {
159+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
160+
}
161+
});
162+
}
163+
}));
164+
}
165+
}
166+
private class DetailedHistoryMenuItem extends MenuItem
167+
{
168+
public DetailedHistoryMenuItem()
169+
{
170+
super(new StringProvider("DetailedHistory"), 0x230010, 0);
171+
this.setCommand(new Command(new CommandHandler()
172+
{
173+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
174+
{
175+
_pubnub.detailedHistory(channel, 1, new Callback() {
176+
public void successCallback(String channel, Object message) {
177+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
178+
}
179+
180+
public void errorCallback(String channel, Object message) {
181+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
182+
}
183+
});
184+
}
185+
}));
186+
}
187+
}
188+
private class SubscribeMenuItem extends MenuItem
189+
{
190+
public SubscribeMenuItem()
191+
{
192+
super(new StringProvider("Subscribe"), 0x230010, 0);
193+
this.setCommand(new Command(new CommandHandler()
194+
{
195+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
196+
{ Hashtable args = new Hashtable(6);
197+
args.put("channels", channels);
198+
199+
try {
200+
_pubnub.subscribe(args, new Callback() {
201+
public void connectCallback(String channel) {
202+
PubnubExample.alertDialog("CONNECT on channel:" + channel);
203+
}
204+
205+
public void disconnectCallback(String channel) {
206+
PubnubExample.alertDialog("DISCONNECT on channel:" + channel);
207+
}
208+
209+
public void reconnectCallback(String channel) {
210+
PubnubExample.alertDialog("RECONNECT on channel:" + channel);
211+
}
212+
213+
public void successCallback(String channel, Object message) {
214+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
215+
}
216+
});
217+
218+
} catch (Exception e) {
219+
220+
}
221+
}
222+
}));
223+
}
224+
}
225+
private class PresenceMenuItem extends MenuItem
226+
{
227+
public PresenceMenuItem()
228+
{
229+
super(new StringProvider("Presence"), 0x230010, 0);
230+
this.setCommand(new Command(new CommandHandler()
231+
{
232+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
233+
{
234+
try {
235+
_pubnub.presence(channel, new Callback() {
236+
public void successCallback(String channel, Object message) {
237+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
238+
}
239+
240+
public void errorCallback(String channel, Object message) {
241+
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
242+
}
243+
});
244+
} catch (PubnubException e) {
245+
246+
}
247+
}
248+
}));
249+
}
250+
}
251+
private class UnsubscribeMenuItem extends MenuItem
252+
{
253+
public UnsubscribeMenuItem()
254+
{
255+
super(new StringProvider("Unsubscribe"), 0x230010, 0);
256+
this.setCommand(new Command(new CommandHandler()
257+
{
258+
public void execute(ReadOnlyCommandMetadata metadata, Object context)
259+
{
260+
_pubnub.unsubscribe(channels);
261+
}
262+
}));
263+
}
264+
}
265+
}
32.1 KB
Binary file not shown.
73.7 KB
Binary file not shown.
13.8 MB
Binary file not shown.

blackberry/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
2+
##### http://www.pubnub.com/account
3+
4+
## PubNub 3.4 Real-time Cloud Push API - BlackBerry
5+
6+
www.pubnub.com - PubNub Real-time Push Service in the Cloud.
7+
8+
Please reference the demo app! Detailed instruction on how to run can be found at: https://s3.amazonaws.com/pubnub/github/Pubnub%2520Blackberry%2520Example%2520App%2520Setup%2520Guide.doc
9+
10+
for an example of how to bring real-time asyncronously in your applications!
11+

0 commit comments

Comments
 (0)