The Pubnub C-core library. It's home is on https://github.com/pubnub/c_core, this is a copy

Dependents:   Pubnub_c_core_mbed2_pal Pubnub_c_core_mbed2_pal Pubnub_c_core_mbed2_pal2

Committer:
sveljko
Date:
Thu Nov 10 22:20:11 2016 +0000
Revision:
0:d13755cfb705
Initial commit of Pubnub C-core

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sveljko 0:d13755cfb705 1 /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
sveljko 0:d13755cfb705 2 #if !defined INC_PUBNUB_API_TYPES
sveljko 0:d13755cfb705 3 #define INC_PUBNUB_API_TYPES
sveljko 0:d13755cfb705 4
sveljko 0:d13755cfb705 5
sveljko 0:d13755cfb705 6 /** @file pubnub_api_types.h
sveljko 0:d13755cfb705 7
sveljko 0:d13755cfb705 8 These are the definitions of types used by most functions of the
sveljko 0:d13755cfb705 9 Pubnub C-core API. Users of the SDK in general don't need to
sveljko 0:d13755cfb705 10 include it, as other headers of the API will include it for them.
sveljko 0:d13755cfb705 11 */
sveljko 0:d13755cfb705 12
sveljko 0:d13755cfb705 13 struct pubnub_;
sveljko 0:d13755cfb705 14
sveljko 0:d13755cfb705 15 /** A pubnub context. An opaque data structure that holds all the data
sveljko 0:d13755cfb705 16 needed for a context.
sveljko 0:d13755cfb705 17 */
sveljko 0:d13755cfb705 18 typedef struct pubnub_ pubnub_t;
sveljko 0:d13755cfb705 19
sveljko 0:d13755cfb705 20
sveljko 0:d13755cfb705 21 /** Result codes for Pubnub functions and transactions. */
sveljko 0:d13755cfb705 22 enum pubnub_res {
sveljko 0:d13755cfb705 23 /** Success. Transaction finished successfully. */
sveljko 0:d13755cfb705 24 PNR_OK,
sveljko 0:d13755cfb705 25 /** Pubnub host name resolution failed. We failed to get
sveljko 0:d13755cfb705 26 an IP address from the Pubnub host name ("origin").
sveljko 0:d13755cfb705 27 Most of the time, this comes down to a DNS error.
sveljko 0:d13755cfb705 28 */
sveljko 0:d13755cfb705 29 PNR_ADDR_RESOLUTION_FAILED,
sveljko 0:d13755cfb705 30 /** Connecting to Pubnub server failed. Most often,
sveljko 0:d13755cfb705 31 this means a network outage, but could be many things.
sveljko 0:d13755cfb705 32 If using SSL/TLS, it could be some of its errors.
sveljko 0:d13755cfb705 33 */
sveljko 0:d13755cfb705 34 PNR_CONNECT_FAILED,
sveljko 0:d13755cfb705 35 /** A time-out happened in the network. Mostly, this is because
sveljko 0:d13755cfb705 36 a network outage happened while being connected to the Pubnub
sveljko 0:d13755cfb705 37 server, but could be other things.
sveljko 0:d13755cfb705 38 */
sveljko 0:d13755cfb705 39 PNR_CONNECTION_TIMEOUT,
sveljko 0:d13755cfb705 40 /** Time-out before the request has completed. This is reported
sveljko 0:d13755cfb705 41 for a time-out detected by Pubnub client itself, not some
sveljko 0:d13755cfb705 42 reported by others (i.e. the TCP/IP stack).
sveljko 0:d13755cfb705 43 */
sveljko 0:d13755cfb705 44 PNR_TIMEOUT,
sveljko 0:d13755cfb705 45 /** Connection to Pubnub aborted (in most cases, a TCP reset was
sveljko 0:d13755cfb705 46 received) */
sveljko 0:d13755cfb705 47 PNR_ABORTED,
sveljko 0:d13755cfb705 48 /** Communication error (network or HTTP response format). */
sveljko 0:d13755cfb705 49 PNR_IO_ERROR,
sveljko 0:d13755cfb705 50 /** HTTP error. Call pubnub_last_http_code() to get the error
sveljko 0:d13755cfb705 51 * code. */
sveljko 0:d13755cfb705 52 PNR_HTTP_ERROR,
sveljko 0:d13755cfb705 53 /** Unexpected input in received JSON. */
sveljko 0:d13755cfb705 54 PNR_FORMAT_ERROR,
sveljko 0:d13755cfb705 55 /** Request cancelled by user. */
sveljko 0:d13755cfb705 56 PNR_CANCELLED,
sveljko 0:d13755cfb705 57 /** Transaction started. Await the outcome. */
sveljko 0:d13755cfb705 58 PNR_STARTED,
sveljko 0:d13755cfb705 59 /** Transaction (already) ongoing. Can't start a new transaction
sveljko 0:d13755cfb705 60 while the old one is in progress. */
sveljko 0:d13755cfb705 61 PNR_IN_PROGRESS,
sveljko 0:d13755cfb705 62 /** Receive buffer (from previous transaction) not read, new
sveljko 0:d13755cfb705 63 subscription not allowed.
sveljko 0:d13755cfb705 64 */
sveljko 0:d13755cfb705 65 PNR_RX_BUFF_NOT_EMPTY,
sveljko 0:d13755cfb705 66 /** The buffer is too small. Increase #PUBNUB_BUF_MAXLEN.
sveljko 0:d13755cfb705 67 */
sveljko 0:d13755cfb705 68 PNR_TX_BUFF_TOO_SMALL,
sveljko 0:d13755cfb705 69 /** Channel specification / name is invalid.
sveljko 0:d13755cfb705 70 */
sveljko 0:d13755cfb705 71 PNR_INVALID_CHANNEL,
sveljko 0:d13755cfb705 72 /** Publish transaction failed - error returned from Pubnub. To
sveljko 0:d13755cfb705 73 see the reason describing the failure, call
sveljko 0:d13755cfb705 74 pubnub_last_publish_result().
sveljko 0:d13755cfb705 75 */
sveljko 0:d13755cfb705 76 PNR_PUBLISH_FAILED,
sveljko 0:d13755cfb705 77 /** A transaction related to channel registry failed - error
sveljko 0:d13755cfb705 78 returned from Pubnub. To see the reason describing the
sveljko 0:d13755cfb705 79 failure, get the value for key "message" from the response
sveljko 0:d13755cfb705 80 (which is a JSON object) and value for key "status" for the
sveljko 0:d13755cfb705 81 numeric code of the error.
sveljko 0:d13755cfb705 82 */
sveljko 0:d13755cfb705 83 PNR_CHANNEL_REGISTRY_ERROR,
sveljko 0:d13755cfb705 84 /** Reply is too big to fit in our reply buffer. This same error
sveljko 0:d13755cfb705 85 is reported if the reply buffer is statically or dynamically
sveljko 0:d13755cfb705 86 allocated.
sveljko 0:d13755cfb705 87 */
sveljko 0:d13755cfb705 88 PNR_REPLY_TOO_BIG,
sveljko 0:d13755cfb705 89 /** An internal error in processing */
sveljko 0:d13755cfb705 90 PNR_INTERNAL_ERROR,
sveljko 0:d13755cfb705 91 /** Encryption (and decryption) not supported */
sveljko 0:d13755cfb705 92 PNR_CRYPTO_NOT_SUPPORTED
sveljko 0:d13755cfb705 93 };
sveljko 0:d13755cfb705 94
sveljko 0:d13755cfb705 95
sveljko 0:d13755cfb705 96 /** Type of Pubnub operation/transaction */
sveljko 0:d13755cfb705 97 enum pubnub_trans {
sveljko 0:d13755cfb705 98 /** No transaction at all */
sveljko 0:d13755cfb705 99 PBTT_NONE,
sveljko 0:d13755cfb705 100 /** Subscribe operation/transaction */
sveljko 0:d13755cfb705 101 PBTT_SUBSCRIBE,
sveljko 0:d13755cfb705 102 /** Publish operation/transaction */
sveljko 0:d13755cfb705 103 PBTT_PUBLISH,
sveljko 0:d13755cfb705 104 /** Leave (channel(s)) operation/transaction */
sveljko 0:d13755cfb705 105 PBTT_LEAVE,
sveljko 0:d13755cfb705 106 /** Time (get from Pubnub server) operation/transaction */
sveljko 0:d13755cfb705 107 PBTT_TIME,
sveljko 0:d13755cfb705 108 /** History V2 (get message history for the channel from Pubnub
sveljko 0:d13755cfb705 109 * server) operation/transaction */
sveljko 0:d13755cfb705 110 PBTT_HISTORY,
sveljko 0:d13755cfb705 111 /** Here-now (get UUIDs of currently present users in channel(s))
sveljko 0:d13755cfb705 112 * operation/transaction */
sveljko 0:d13755cfb705 113 PBTT_HERENOW,
sveljko 0:d13755cfb705 114 /** Global here-now (get UUIDs of currently present users in all
sveljko 0:d13755cfb705 115 channels) operation/transaction */
sveljko 0:d13755cfb705 116 PBTT_GLOBAL_HERENOW,
sveljko 0:d13755cfb705 117 /** Where-now (get channels in which an user (identified by UUID)
sveljko 0:d13755cfb705 118 is currently present) operation/transaction */
sveljko 0:d13755cfb705 119 PBTT_WHERENOW,
sveljko 0:d13755cfb705 120 /** Set state (for a user (identified by UUID) on channel(s))
sveljko 0:d13755cfb705 121 * operation/transaction */
sveljko 0:d13755cfb705 122 PBTT_SET_STATE,
sveljko 0:d13755cfb705 123 /** Get state (for a user (identified by UUID) on channel(s))
sveljko 0:d13755cfb705 124 * operation/transaction */
sveljko 0:d13755cfb705 125 PBTT_STATE_GET,
sveljko 0:d13755cfb705 126 /** Remove a channel group (from the channel-registry)
sveljko 0:d13755cfb705 127 * operation/transaction */
sveljko 0:d13755cfb705 128 PBTT_REMOVE_CHANNEL_GROUP,
sveljko 0:d13755cfb705 129 /** Remove a channel from a channel group (in the channel-registry)
sveljko 0:d13755cfb705 130 * operation/transaction */
sveljko 0:d13755cfb705 131 PBTT_REMOVE_CHANNEL_FROM_GROUP,
sveljko 0:d13755cfb705 132 /** Add a channel to a channel group (in the channel-registry)
sveljko 0:d13755cfb705 133 * operation/transaction */
sveljko 0:d13755cfb705 134 PBTT_ADD_CHANNEL_TO_GROUP,
sveljko 0:d13755cfb705 135 /** Get a list of all channels in a channel group (from the
sveljko 0:d13755cfb705 136 * channel-registry) operation/transaction */
sveljko 0:d13755cfb705 137 PBTT_LIST_CHANNEL_GROUP,
sveljko 0:d13755cfb705 138 /** Inform Pubnub that we're still working on @p channel and/or @p
sveljko 0:d13755cfb705 139 channel_group operation/transaction */
sveljko 0:d13755cfb705 140 PBTT_HEARTBEAT,
sveljko 0:d13755cfb705 141 };
sveljko 0:d13755cfb705 142
sveljko 0:d13755cfb705 143
sveljko 0:d13755cfb705 144 #endif /* !defined INC_PUBNUB_API_TYPES */