WPILibC++  2018.4.1-20180729133221-1141-g00c2cd7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Connection Listener Functions

Typedefs

typedef void(* NT_ConnectionListenerCallback )(void *data, const struct NT_ConnectionNotification *event)
 Connection listener callback function. More...
 

Functions

NT_ConnectionListener NT_AddConnectionListener (NT_Inst inst, void *data, NT_ConnectionListenerCallback callback, NT_Bool immediate_notify)
 Add a connection listener. More...
 
NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller (NT_Inst inst)
 Create a connection listener poller. More...
 
void NT_DestroyConnectionListenerPoller (NT_ConnectionListenerPoller poller)
 Destroy a connection listener poller. More...
 
NT_ConnectionListener NT_AddPolledConnectionListener (NT_ConnectionListenerPoller poller, NT_Bool immediate_notify)
 Create a polled connection listener. More...
 
struct NT_ConnectionNotificationNT_PollConnectionListener (NT_ConnectionListenerPoller poller, size_t *len)
 Get the next connection event. More...
 
struct NT_ConnectionNotificationNT_PollConnectionListenerTimeout (NT_ConnectionListenerPoller poller, size_t *len, double timeout, NT_Bool *timed_out)
 Get the next connection event. More...
 
void NT_CancelPollConnectionListener (NT_ConnectionListenerPoller poller)
 Cancel a PollConnectionListener call. More...
 
void NT_RemoveConnectionListener (NT_ConnectionListener conn_listener)
 Remove a connection listener. More...
 
NT_Bool NT_WaitForConnectionListenerQueue (NT_Inst inst, double timeout)
 Wait for the connection listener queue to be empty. More...
 

Detailed Description

Typedef Documentation

typedef void(* NT_ConnectionListenerCallback)(void *data, const struct NT_ConnectionNotification *event)

Connection listener callback function.

Called when a network connection is made or lost.

Parameters
datadata pointer provided to callback creation function
eventevent info

Function Documentation

NT_ConnectionListener NT_AddConnectionListener ( NT_Inst  inst,
void *  data,
NT_ConnectionListenerCallback  callback,
NT_Bool  immediate_notify 
)

Add a connection listener.

Parameters
instinstance handle
datadata pointer to pass to callback
callbacklistener to add
immediate_notifynotify listener of all existing connections
Returns
Listener handle
NT_ConnectionListener NT_AddPolledConnectionListener ( NT_ConnectionListenerPoller  poller,
NT_Bool  immediate_notify 
)

Create a polled connection listener.

The caller is responsible for calling NT_PollConnectionListener() to poll.

Parameters
pollerpoller handle
immediate_notifynotify listener of all existing connections
void NT_CancelPollConnectionListener ( NT_ConnectionListenerPoller  poller)

Cancel a PollConnectionListener call.

This wakes up a call to PollConnectionListener for this poller and causes it to immediately return an empty array.

Parameters
pollerpoller handle
NT_ConnectionListenerPoller NT_CreateConnectionListenerPoller ( NT_Inst  inst)

Create a connection listener poller.

A poller provides a single queue of poll events. Events linked to this poller (using NT_AddPolledConnectionListener()) will be stored in the queue and must be collected by calling NT_PollConnectionListener(). The returned handle must be destroyed with NT_DestroyConnectionListenerPoller().

Parameters
instinstance handle
Returns
poller handle
void NT_DestroyConnectionListenerPoller ( NT_ConnectionListenerPoller  poller)

Destroy a connection listener poller.

This will abort any blocked polling call and prevent additional events from being generated for this poller.

Parameters
pollerpoller handle
struct NT_ConnectionNotification* NT_PollConnectionListener ( NT_ConnectionListenerPoller  poller,
size_t *  len 
)

Get the next connection event.

This blocks until the next connect or disconnect occurs. This is intended to be used with NT_AddPolledConnectionListener(); connection listeners created using NT_AddConnectionListener() will not be serviced through this function.

Parameters
pollerpoller handle
lenlength of returned array (output)
Returns
Array of information on the connection events. Only returns NULL if an error occurred (e.g. the instance was invalid or is shutting down).
struct NT_ConnectionNotification* NT_PollConnectionListenerTimeout ( NT_ConnectionListenerPoller  poller,
size_t *  len,
double  timeout,
NT_Bool timed_out 
)

Get the next connection event.

This blocks until the next connect or disconnect occurs or it times out. This is intended to be used with NT_AddPolledConnectionListener(); connection listeners created using NT_AddConnectionListener() will not be serviced through this function.

Parameters
pollerpoller handle
lenlength of returned array (output)
timeouttimeout, in seconds
timed_outtrue if the timeout period elapsed (output)
Returns
Array of information on the connection events. If NULL is returned and timed_out is also false, an error occurred (e.g. the instance was invalid or is shutting down).
void NT_RemoveConnectionListener ( NT_ConnectionListener  conn_listener)

Remove a connection listener.

Parameters
conn_listenerListener handle to remove
NT_Bool NT_WaitForConnectionListenerQueue ( NT_Inst  inst,
double  timeout 
)

Wait for the connection listener queue to be empty.

This is primarily useful for deterministic testing. This blocks until either the connection listener queue is empty (e.g. there are no more events that need to be passed along to callbacks or poll queues) or the timeout expires.

Parameters
instinstance handle
timeouttimeout, in seconds. Set to 0 for non-blocking behavior, or a negative value to block indefinitely
Returns
False if timed out, otherwise true.