Loading...
Searching...
No Matches
Libevent Adapter

## Functions

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

## 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

  userData | the location where the adapter stores the user object passed to the other callbacks.
  loop | the event loop as a generic pointer. Cast to appropriate type.
  nc | the connection to attach to the event loop
  socket | the 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

  userData | the user object created in natsLibevent_Attach
  add | `true` 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

  userData | the user object created in natsLibevent_Attach
  add | `true` 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

  userData | the user object created in natsLibevent_Attach