WPILibC++
2018.4.1-20180728210220-1136-g75a6720
|
Functions | |
void | nt::CreateRpc (NT_Entry entry, StringRef def, std::function< void(const RpcAnswer &answer)> callback) |
Create a callback-based RPC entry point. More... | |
NT_RpcCallPoller | nt::CreateRpcCallPoller (NT_Inst inst) |
Create a RPC call poller. More... | |
void | nt::DestroyRpcCallPoller (NT_RpcCallPoller poller) |
Destroy a RPC call poller. More... | |
void | nt::CreatePolledRpc (NT_Entry entry, StringRef def, NT_RpcCallPoller poller) |
Create a polled RPC entry point. More... | |
std::vector< RpcAnswer > | nt::PollRpc (NT_RpcCallPoller poller) |
Get the next incoming RPC call. More... | |
std::vector< RpcAnswer > | nt::PollRpc (NT_RpcCallPoller poller, double timeout, bool *timed_out) |
Get the next incoming RPC call. More... | |
void | nt::CancelPollRpc (NT_RpcCallPoller poller) |
Cancel a PollRpc call. More... | |
bool | nt::WaitForRpcCallQueue (NT_Inst inst, double timeout) |
Wait for the incoming RPC call queue to be empty. More... | |
bool | nt::PostRpcResponse (NT_Entry entry, NT_RpcCall call, StringRef result) |
Post RPC response (return value) for a polled RPC. More... | |
NT_RpcCall | nt::CallRpc (NT_Entry entry, StringRef params) |
Call a RPC function. More... | |
bool | nt::GetRpcResult (NT_Entry entry, NT_RpcCall call, std::string *result) |
Get the result (return value) of a RPC call. More... | |
bool | nt::GetRpcResult (NT_Entry entry, NT_RpcCall call, std::string *result, double timeout, bool *timed_out) |
Get the result (return value) of a RPC call. More... | |
void | nt::CancelRpcResult (NT_Entry entry, NT_RpcCall call) |
Ignore the result of a RPC call. More... | |
std::string | nt::PackRpcDefinition (const RpcDefinition &def) |
Pack a RPC version 1 definition. More... | |
bool | nt::UnpackRpcDefinition (StringRef packed, RpcDefinition *def) |
Unpack a RPC version 1 definition. More... | |
std::string | nt::PackRpcValues (ArrayRef< std::shared_ptr< Value >> values) |
Pack RPC values as required for RPC version 1 definition messages. More... | |
std::vector< std::shared_ptr < Value > > | nt::UnpackRpcValues (StringRef packed, ArrayRef< NT_Type > types) |
Unpack RPC values as required for RPC version 1 definition messages. More... | |
NT_RpcCall nt::CallRpc | ( | NT_Entry | entry, |
StringRef | params | ||
) |
Call a RPC function.
May be used on either the client or server. This function is non-blocking. Either GetRpcResult() or CancelRpcResult() must be called to either get or ignore the result of the call.
entry | entry handle of RPC entry |
params | parameter |
void nt::CancelPollRpc | ( | NT_RpcCallPoller | poller | ) |
Cancel a PollRpc call.
This wakes up a call to PollRpc for this poller and causes it to immediately return an empty array.
poller | poller handle |
void nt::CancelRpcResult | ( | NT_Entry | entry, |
NT_RpcCall | call | ||
) |
Ignore the result of a RPC call.
This function is non-blocking.
entry | entry handle of RPC entry |
call | RPC call handle returned by CallRpc() |
void nt::CreatePolledRpc | ( | NT_Entry | entry, |
StringRef | def, | ||
NT_RpcCallPoller | poller | ||
) |
Create a polled RPC entry point.
Only valid to use on the server. The caller is responsible for calling PollRpc() to poll for servicing incoming RPC calls.
entry | entry handle of RPC entry |
def | RPC definition |
poller | poller handle |
void nt::CreateRpc | ( | NT_Entry | entry, |
StringRef | def, | ||
std::function< void(const RpcAnswer &answer)> | callback | ||
) |
Create a callback-based RPC entry point.
Only valid to use on the server. The callback function will be called when the RPC is called.
entry | entry handle of RPC entry |
def | RPC definition |
callback | callback function; note the callback function must call PostRpcResponse() to provide a response to the call |
NT_RpcCallPoller nt::CreateRpcCallPoller | ( | NT_Inst | inst | ) |
Create a RPC call poller.
Only valid to use on the server.
A poller provides a single queue of poll events. Events linked to this poller (using CreatePolledRpc()) will be stored in the queue and must be collected by calling PollRpc(). The returned handle must be destroyed with DestroyRpcCallPoller().
inst | instance handle |
void nt::DestroyRpcCallPoller | ( | NT_RpcCallPoller | poller | ) |
Destroy a RPC call poller.
This will abort any blocked polling call and prevent additional events from being generated for this poller.
poller | poller handle |
bool nt::GetRpcResult | ( | NT_Entry | entry, |
NT_RpcCall | call, | ||
std::string * | result | ||
) |
Get the result (return value) of a RPC call.
This function blocks until the result is received.
entry | entry handle of RPC entry |
call | RPC call handle returned by CallRpc() |
result | received result (output) |
bool nt::GetRpcResult | ( | NT_Entry | entry, |
NT_RpcCall | call, | ||
std::string * | result, | ||
double | timeout, | ||
bool * | timed_out | ||
) |
Get the result (return value) of a RPC call.
This function blocks until the result is received or it times out.
entry | entry handle of RPC entry |
call | RPC call handle returned by CallRpc() |
result | received result (output) |
timeout | timeout, in seconds |
timed_out | true if the timeout period elapsed (output) |
std::string nt::PackRpcDefinition | ( | const RpcDefinition & | def | ) |
Pack a RPC version 1 definition.
def | RPC version 1 definition |
std::string nt::PackRpcValues | ( | ArrayRef< std::shared_ptr< Value >> | values | ) |
Pack RPC values as required for RPC version 1 definition messages.
values | array of values to pack |
std::vector<RpcAnswer> nt::PollRpc | ( | NT_RpcCallPoller | poller | ) |
Get the next incoming RPC call.
This blocks until the next incoming RPC call is received. This is intended to be used with CreatePolledRpc(); RPC calls created using CreateRpc() will not be serviced through this function. Upon successful return, PostRpcResponse() must be called to send the return value to the caller.
poller | poller handle |
std::vector<RpcAnswer> nt::PollRpc | ( | NT_RpcCallPoller | poller, |
double | timeout, | ||
bool * | timed_out | ||
) |
Get the next incoming RPC call.
This blocks until the next incoming RPC call is received or it times out. This is intended to be used with CreatePolledRpc(); RPC calls created using CreateRpc() will not be serviced through this function. Upon successful return, PostRpcResponse() must be called to send the return value to the caller.
poller | poller handle |
timeout | timeout, in seconds |
timed_out | true if the timeout period elapsed (output) |
bool nt::PostRpcResponse | ( | NT_Entry | entry, |
NT_RpcCall | call, | ||
StringRef | result | ||
) |
Post RPC response (return value) for a polled RPC.
The rpc and call parameters should come from the RpcAnswer returned by PollRpc().
entry | entry handle of RPC entry (from RpcAnswer) |
call | RPC call handle (from RpcAnswer) |
result | result raw data that will be provided to remote caller |
bool nt::UnpackRpcDefinition | ( | StringRef | packed, |
RpcDefinition * | def | ||
) |
Unpack a RPC version 1 definition.
This can be used for introspection or validation.
packed | raw packed bytes |
def | RPC version 1 definition (output) |
std::vector<std::shared_ptr<Value> > nt::UnpackRpcValues | ( | StringRef | packed, |
ArrayRef< NT_Type > | types | ||
) |
Unpack RPC values as required for RPC version 1 definition messages.
packed | raw packed bytes |
types | array of data types (as provided in the RPC definition) |
bool nt::WaitForRpcCallQueue | ( | NT_Inst | inst, |
double | timeout | ||
) |
Wait for the incoming RPC call queue to be empty.
This is primarily useful for deterministic testing. This blocks until either the RPC call 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.
inst | instance handle |
timeout | timeout, in seconds. Set to 0 for non-blocking behavior, or a negative value to block indefinitely |