Skip to content

Commit 98573bb

Browse files
author
Devendra
committed
adding metadata support in heartbeat and subscribe requests
1 parent 010a1f6 commit 98573bb

34 files changed

Lines changed: 137 additions & 41 deletions

android/Pubnub-Android-3.6.0.jar

391 Bytes
Binary file not shown.
391 Bytes
Binary file not shown.

android/examples/PubnubExample/res/layout/usage.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
android:layout_width="wrap_content"
151151
android:layout_height="wrap_content"
152152
android:text="@string/option21" />
153+
<TextView
154+
android:id="@+id/option22"
155+
android:layout_width="wrap_content"
156+
android:layout_height="wrap_content"
157+
android:text="@string/option22" />
153158
</LinearLayout>
154159

155160
</LinearLayout>

android/examples/PubnubExample/res/menu/activity_main.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<item android:id="@+id/option18" android:title="@string/option18" android:titleCondensed="@string/option18"></item>
2020
<item android:id="@+id/option19" android:title="@string/option19" android:titleCondensed="@string/option19"></item>
2121
<item android:id="@+id/option20" android:title="@string/option20" android:titleCondensed="@string/option20"></item>
22-
<item android:id="@+id/option21" android:title="@string/option21" android:titleCondensed="@string/option21"></item>
22+
<item android:id="@+id/option21" android:title="@string/option21" android:titleCondensed="@string/option21"></item>
23+
<item android:id="@+id/option22" android:title="@string/option22" android:titleCondensed="@string/option22"></item>
2324
</menu>

android/examples/PubnubExample/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@
3838
<string name="option19">Toggle Cache Busting</string>
3939
<string name="option20">Set Presence Expiry</string>
4040
<string name="option21">Set UUID</string>
41+
<string name="option22">Set State</string>
4142
</resources>

android/examples/PubnubExample/src/com/pubnub/examples/pubnubExample/MainActivity.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,45 @@ public void errorCallback(String channel,
357357
alert.show();
358358

359359
}
360+
361+
private void _metadata(final String channel) {
362+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
363+
builder.setTitle("Set Metadata");
364+
builder.setMessage("Enter message");
365+
final EditText etMessage = new EditText(this);
366+
builder.setView(etMessage);
367+
builder.setPositiveButton("Submit",
368+
new DialogInterface.OnClickListener() {
369+
370+
@Override
371+
public void onClick(DialogInterface dialog, int which) {
372+
Callback setMetaDataCallback = new Callback() {
373+
@Override
374+
public void successCallback(String channel,
375+
Object message) {
376+
notifyUser("SET METADATA : " + message);
377+
}
378+
@Override
379+
public void errorCallback(String channel,
380+
PubnubError error) {
381+
notifyUser("SET METADATA : " + error);
382+
}
383+
};
384+
385+
String message = etMessage.getText().toString();
386+
try {
387+
JSONObject js = new JSONObject(message);
388+
pubnub.setState(channel, pubnub.getUUID(), js, setMetaDataCallback);
389+
return;
390+
} catch (Exception e) {}
391+
392+
pubnub.publish(channel, message, setMetaDataCallback);
393+
}
394+
395+
});
396+
AlertDialog alert = builder.create();
397+
alert.show();
398+
}
360399

361400
private void _publish(final String channel) {
362401
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -435,6 +474,25 @@ public void onClick(DialogInterface dialog, int which) {
435474
AlertDialog alert = builder.create();
436475
alert.show();
437476
}
477+
478+
private void setState() {
479+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
480+
builder.setTitle("Set Metadata ");
481+
builder.setMessage("Enter channel name");
482+
final EditText etChannel = new EditText(this);
483+
builder.setView(etChannel);
484+
builder.setPositiveButton("Done",
485+
new DialogInterface.OnClickListener() {
486+
487+
@Override
488+
public void onClick(DialogInterface dialog, int which) {
489+
_metadata(etChannel.getText().toString());
490+
}
491+
492+
});
493+
AlertDialog alert = builder.create();
494+
alert.show();
495+
}
438496

439497
private void presence() {
440498

391 Bytes
Binary file not shown.
321 Bytes
Binary file not shown.

java/doc/allclasses-frame.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_65) on Sat Feb 01 20:16:19 GMT+05:30 2014 -->
5+
<!-- Generated by javadoc (build 1.6.0_65) on Thu Feb 06 02:43:54 GMT+05:30 2014 -->
66
<TITLE>
77
All Classes
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2014-02-01">
10+
<META NAME="date" CONTENT="2014-02-06">
1111

1212
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
1313

java/doc/allclasses-noframe.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<!--NewPage-->
33
<HTML>
44
<HEAD>
5-
<!-- Generated by javadoc (build 1.6.0_65) on Sat Feb 01 20:16:19 GMT+05:30 2014 -->
5+
<!-- Generated by javadoc (build 1.6.0_65) on Thu Feb 06 02:43:54 GMT+05:30 2014 -->
66
<TITLE>
77
All Classes
88
</TITLE>
99

10-
<META NAME="date" CONTENT="2014-02-01">
10+
<META NAME="date" CONTENT="2014-02-06">
1111

1212
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
1313

0 commit comments

Comments
 (0)