Utility Methods API for POSIX C++ SDK
The methods on this page are utility methods that don't fit into other categories.
Class pubnub::subloop
Declaration
namespace pubnub { class subloop; }
Description
A helper class for a subscribe loop. Supports both a piecemal
, message-by-message, interface and a callback-like
interface.
Constructor
Declaration
subloop(context &ctx, std::string channel);
Description
Creates a subscribe loop, ready to do the looping. We assume that the @p
ctx
PubNub context will be valid throughout the lifetime of this object.
Parameters
Parameter | Description |
---|---|
ctx *Type: pubnub::context & | The PubNub context to use for the loop. |
channel *Type: std::string | The channel(s) to subscribe to in the loop. |
Sample code
pubnub::subloop sublup(ctx, "hello_world");
Enums
Enum type: pubnub_res
Result codes for Functions and transactions.
Members
PNR_OK
Success. Transaction finished successfully.
PNR_ADDR_RESOLUTION_FAILED
Pubnub host name resolution failed. We failed to get an IP address from the PubNub host name (origin
). Most of the time, this comes down to a DNS error.
PNR_CONNECT_FAILED
Connecting to Pubnub server failed. Most often, this means a network outage, but could be many things. If using SSL/TLS
, it could be some of its errors.
PNR_CONNECTION_TIMEOUT
A time-out happened in the network. Mostly, this is because a network outage happened while being connected to the PubNub server, but could be other things.
PNR_TIMEOUT
Time-out before the request has completed. This is reported for a time-out detected by PubNub client itself, not some reported by others (that is, the TCP/IP
stack).
PNR_ABORTED
Connection to Pubnub aborted (in most cases, a TCP
reset was received).
PNR_IO_ERROR
Communication error (network or HTTP
response format).
PNR_HTTP_ERROR
HTTP
error. Call pubnub_last_http_code()
to get the error code.
PNR_FORMAT_ERROR
Unexpected input in received JSON
.
PNR_CANCELLED
Request cancelled by user.