Build Realtime Apps With The Real-Time Network - the mbed PubNub API+SDK
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 5:1c98f24712e1, committed 2014-09-01
- Comitter:
- Petr Baudis
- Date:
- Mon Sep 01 00:12:11 2014 +0200
- Parent:
- 4:a4759c403023
- Commit message:
- http_send_headers(): Include trailing pnsdk query parameter in URL
Changed in this revision
PubNub.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/PubNub.cpp Sun Mar 02 01:48:40 2014 +0000 +++ b/PubNub.cpp Mon Sep 01 00:12:11 2014 +0200 @@ -127,7 +127,7 @@ PubNubHTTP::http_send_headers(const char *host) { /* Finish the first line of the request. */ - sendstr(" HTTP/1.1\r\n"); + sendstr("?pnsdk=PubNub-mbed/0.1 HTTP/1.1\r\n"); /* Finish HTTP request. */ sendstr("Host: "); sendstr(host); @@ -525,4 +525,4 @@ free(reply); return PNR_OK; -} \ No newline at end of file +}