NATS C Client with JetStream and Streaming support  3.9.1
The nats.io C Client, Supported by Synadia Communications Inc.
Libevent Adapter

Functions

void natsLibevent_Init (void)
 Initialize the adapter. More...
 
natsStatus natsLibevent_Attach (void **userData, void *loop, natsConnection *nc, natsSock socket)
 Attach a connection to the given event loop. More...
 
natsStatus natsLibevent_Read (void *userData, bool add)
 Start or stop polling on READ events. More...
 
natsStatus natsLibevent_Write (void *userData, bool add)
 Start or stop polling on WRITE events. More...
 
natsStatus natsLibevent_Detach (void *userData)
 The connection is closed, it can be safely detached. More...
 

Detailed Description

Adapter to plug a NATS connection to a libevent event loop.

Function Documentation

◆ natsLibevent_Init()

void natsLibevent_Init ( void  )

Needs to be called once so that the adapter can initialize some state.

◆ natsLibevent_Attach()

natsStatus natsLibevent_Attach ( void **  userData,
void *  loop,
natsConnection nc,
natsSock  socket 
)

This callback is invoked after NATS library has connected, or reconnected. For a reconnect event, *userData will not be NULL. This function will start polling on READ events for the given socket.

Parameters
userDatathe location where the adapter stores the user object passed to the other callbacks.
loopthe event loop as a generic pointer. Cast to appropriate type.
ncthe connection to attach to the event loop
socketthe socket to start polling on.

◆ natsLibevent_Read()

natsStatus natsLibevent_Read ( void *  userData,
bool  add 
)

This callback is invoked to notify that the event library should start or stop polling for READ events.

Parameters
userDatathe user object created in natsLibevent_Attach
addtrue if the library needs to start polling, false otherwise.

◆ natsLibevent_Write()

natsStatus natsLibevent_Write ( void *  userData,
bool  add 
)

This callback is invoked to notify that the event library should start or stop polling for WRITE events.

Parameters
userDatathe user object created in natsLibevent_Attach
addtrue if the library needs to start polling, false otherwise.

◆ natsLibevent_Detach()

natsStatus natsLibevent_Detach ( void *  userData)

When a connection is closed (not disconnected, pending a reconnect), this callback will be invoked. This is the opportunity to cleanup the state maintained by the adapter for this connection.

Parameters
userDatathe user object created in natsLibevent_Attach