NATS C Client with JetStream and Streaming support  3.8.0
The nats.io C Client, Supported by Synadia Communications Inc.
Loading...
Searching...
No Matches

Functions

NATS_EXTERN natsStatus stanConnection_Publish (stanConnection *sc, const char *channel, const void *data, int dataLen)
 Publishes data on a channel.
 
NATS_EXTERN natsStatus stanConnection_PublishAsync (stanConnection *sc, const char *channel, const void *data, int dataLen, stanPubAckHandler ah, void *ahClosure)
 Asynchronously publishes data on a channel.
 

Detailed Description

Publishing functions

Function Documentation

◆ stanConnection_Publish()

NATS_EXTERN natsStatus stanConnection_Publish ( stanConnection * sc,
const char * channel,
const void * data,
int dataLen )

Publishes the data argument to the given channel. The data argument is left untouched and needs to be correctly interpreted on the receiver.

Parameters
scthe pointer to the stanConnection object.
channelthe channel name the data is sent to.
datathe data to be sent, can be NULL.
dataLenthe length of the data to be sent.

◆ stanConnection_PublishAsync()

NATS_EXTERN natsStatus stanConnection_PublishAsync ( stanConnection * sc,
const char * channel,
const void * data,
int dataLen,
stanPubAckHandler ah,
void * ahClosure )

Publishes the data argument to the given channel. The data argument is left untouched and needs to be correctly interpreted on the receiver.

This function does not wait for an acknowledgment back from the server. Instead, the library will invoke the provided callback when that acknowledgment comes.

In order to correlate the acknowledgment with the published message, you can use the ahClosure since this will be passed to the stanPubAckHandler on every invocation. In other words, you should use a unique closure for each published message.

Parameters
scthe pointer to the natsConnection object.
channelthe channel name the data is sent to.
datathe data to be sent, can be NULL.
dataLenthe length of the data to be sent.
ahthe publish acknowledgment callback. If NULL the user will not be notified of the publish result.
ahClosurethe closure the library will pass to the ah callback if one has been set.