WPILibC++  2019.1.1-beta-2-8-g9207d78
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Connection Listener Functions

Typedefs

typedef std::function< void(NT_ConnectionListener
conn_listener, bool connected,
const ConnectionInfo &conn)> 
nt::ConnectionListenerCallback
 Connection listener callback function. More...
 

Functions

NT_ConnectionListener nt::AddConnectionListener (ConnectionListenerCallback callback, bool immediate_notify)
 Add a connection listener. More...
 
NT_ConnectionListener nt::AddConnectionListener (NT_Inst inst, std::function< void(const ConnectionNotification &event)> callback, 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, bool immediate_notify)
 Create a polled connection listener. More...
 
std::vector
< ConnectionNotification > 
nt::PollConnectionListener (NT_ConnectionListenerPoller poller)
 Get the next connection event. More...
 
std::vector
< ConnectionNotification > 
nt::PollConnectionListener (NT_ConnectionListenerPoller poller, double timeout, 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...
 
bool nt::WaitForConnectionListenerQueue (NT_Inst inst, double timeout)
 Wait for the connection listener queue to be empty. More...
 

Detailed Description

Typedef Documentation

typedef std::function<void(NT_ConnectionListener conn_listener, bool connected, const ConnectionInfo& conn)> nt::ConnectionListenerCallback

Connection listener callback function.

Called when a network connection is made or lost.

Parameters
conn_listenerconnection listener handle returned by callback creation function
connectedtrue if event is due to connection being established
connconnection info

Function Documentation

NT_ConnectionListener nt::AddConnectionListener ( ConnectionListenerCallback  callback,
bool  immediate_notify 
)

Add a connection listener.

Parameters
callbacklistener to add
immediate_notifynotify listener of all existing connections
Returns
Listener handle
NT_ConnectionListener nt::AddConnectionListener ( NT_Inst  inst,
std::function< void(const ConnectionNotification &event)>  callback,
bool  immediate_notify 
)

Add a connection listener.

Parameters
callbacklistener to add
immediate_notifynotify listener of all existing connections
Returns
Listener handle
Parameters
instinstance handle
NT_ConnectionListener nt::AddPolledConnectionListener ( NT_ConnectionListenerPoller  poller,
bool  immediate_notify 
)

Create a polled connection listener.

The caller is responsible for calling 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 AddPolledConnectionListener()) will be stored in the queue and must be collected by calling PollConnectionListener(). The returned handle must be destroyed with 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
std::vector<ConnectionNotification> nt::PollConnectionListener ( NT_ConnectionListenerPoller  poller)

Get the next connection event.

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

Parameters
pollerpoller handle
Returns
Information on the connection events. Only returns empty if an error occurred (e.g. the instance was invalid or is shutting down).
std::vector<ConnectionNotification> nt::PollConnectionListener ( NT_ConnectionListenerPoller  poller,
double  timeout,
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 AddPolledConnectionListener(); connection listeners created using AddConnectionListener() will not be serviced through this function.

Parameters
pollerpoller handle
timeouttimeout, in seconds
timed_outtrue if the timeout period elapsed (output)
Returns
Information on the connection events. If empty 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
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.