Build Realtime Apps With The Real-Time Network - the mbed PubNub API+SDK

PubNub

The PubNub library enables your mbed board to communicate with the world via the PubNub cloud messaging system.

The library provides a PubNub class that is tied to a particular set of keys and offers methods that correspond to the appropriate API methods - publish, subscribe, history, etc. The JSON encoded messages are passed as raw strings to conserve memory, but at your option, you can use e.g. picojson library to deal with JSON. The API is synchronous - use multiple rtos threads to talk to PubNub on the background.

Getting Started

Can't wait to try it out? Connect your mbed application board and proceed to the demo project:

Import programPubNubDemo

Reference demo of the PubNub library for the mbed application board - control your board over the internet!

Library Usage

Import library

Public Member Functions

PubNub (const char *publish_key, const char *subscribe_key, const char *origin="http://pubsub.pubnub.com")
Init a Pubnub Client context.
PubNubRes publish (const char *channel, const char *message, char **reply=NULL)
Publish API call.
PubNubRes subscribe (const char *channel, char **reply)
Subscribe API call.
PubNubRes history (const char *channel, char **reply, int *replysize, int limit=10)
History API call.
PubNubRes time (char *ts)
Time API call.
Revision:
1:29cc485dcdb1
Parent:
0:9858347c382d
Child:
2:d78239c9ebb8
--- a/PubNub.h	Sun Mar 02 01:32:54 2014 +0000
+++ b/PubNub.h	Sun Mar 02 01:41:18 2014 +0000
@@ -64,6 +64,17 @@
 };
 
 
+/** A PubNub Client context. Declare it as a local or global variable,
+ * then you may start calling the API immediately.
+ *
+ * All methods are blocking; if you need to communicate with
+ * PubNub asynchronously, run PubNub in a dedicated thread.
+ * Always use the PubNub context only in a single thread at once.
+ *
+ * Message are passed as strings instead of JSON structures due
+ * to much higher RAM efficiency.  Often, ad hoc composing and
+ * parsing JSON messages will work fine in practice.  Otherwise,
+ * take a look at e.g. the picojson library. */
 class PubNub {
 public:
     /** Init a Pubnub Client context
@@ -72,15 +83,6 @@
      * overwrite or free the memory where you stored the keys!
      * (If you are passing string literals, don't worry about it.)
      *
-     * All methods are blocking; if you need to communicate with
-     * PubNub asynchronously, run PubNub in a dedicated thread.
-     * Always use the PubNub context only in a single thread at once.
-     *
-     * Message are passed as strings instead of JSON structures due
-     * to much higher RAM efficiency.  Often, ad hoc composing and
-     * parsing JSON messages will work fine in practice.  Otherwise,
-     * take a look at e.g. the picojson library.
-     *
      * @param string publish_key required key to send messages.
      * @param string subscribe_key required key to receive messages.
      * @param string origin optional setting for cloud origin.