From 912a373b12add9b939e512acd6dea22f12f26ce4 Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 27 Apr 2021 13:16:31 +0200 Subject: [PATCH] libwutsocket: Change ACConnect() to ACConnectAsync(), Add ACClose() --- include/nn/ac/ac_c.h | 26 ++++++++++++++++++++++- include/nn/ac/ac_cpp.h | 28 +++++++++++++++++++++++++ libraries/wutsocket/wut_socket_common.c | 3 ++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/include/nn/ac/ac_c.h b/include/nn/ac/ac_c.h index 1093b3f..4f8a808 100644 --- a/include/nn/ac/ac_c.h +++ b/include/nn/ac/ac_c.h @@ -44,7 +44,8 @@ void ACFinalize(); /** - * Connects to a network, using the default configuration + * Connects synchronically to a network, using the default configuration + * May be blocking until the console successfully connects or has an timeout. * * \return * A \link nn_result Result\endlink - see \link NNResult_IsSuccess \endlink @@ -53,6 +54,29 @@ ACFinalize(); NNResult ACConnect(); +/** + * Connects asynchronically to a network, using the default configuration + * + * \return + * A \link nn_result Result\endlink - see \link NNResult_IsSuccess \endlink + * and \link NNResult_IsFailure \endlink. + */ +NNResult +ACConnectAsync(); + +/** + * Closes connections made with ACConnect. Use GetCloseStatus to get the status. + * + * \return + * A \link nn_result Result\endlink - see \link NNResult_IsSuccess \endlink + * and \link NNResult_IsFailure \endlink. + */ +NNResult +ACClose(); + +NNResult +ACGetCloseStatus(); + /** * Checks whether the console is currently connected to a network. * diff --git a/include/nn/ac/ac_cpp.h b/include/nn/ac/ac_cpp.h index c234235..adbcb2a 100644 --- a/include/nn/ac/ac_cpp.h +++ b/include/nn/ac/ac_cpp.h @@ -38,6 +38,10 @@ extern "C" nn::Result Initialize__Q2_2nn2acFv(); void Finalize__Q2_2nn2acFv(); +nn::Result Connect__Q2_2nn2acFv(); +nn::Result ConnectAsync__Q2_2nn2acFv(); +nn::Result Close__Q2_2nn2acFv(); +nn::Result GetCloseStatus__Q2_2nn2acFPQ3_2nn2ac6Status(); nn::Result GetStartupId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum(ConfigIdNum *id); nn::Result Connect__Q2_2nn2acFQ3_2nn2ac11ConfigIdNum(ConfigIdNum id); nn::Result GetAssignedAddress__Q2_2nn2acFPUl(uint32_t *ip); @@ -94,6 +98,30 @@ GetStartupId(ConfigIdNum *id) return detail::GetStartupId__Q2_2nn2acFPQ3_2nn2ac11ConfigIdNum(id); } +static inline nn::Result +Connect() +{ + return detail::Connect__Q2_2nn2acFv(); +} + +static inline nn::Result +ConnectAsync() +{ + return detail::ConnectAsync__Q2_2nn2acFv(); +} + +static inline nn::Result +Close() +{ + return detail::Close__Q2_2nn2acFv(); +} + +static inline nn::Result +GetCloseStatus() +{ + return detail::GetCloseStatus__Q2_2nn2acFPQ3_2nn2ac6Status(); +} + /** * Connects to a network, using the configuration represented by the given * \link ConfigIdNum \endlink. diff --git a/libraries/wutsocket/wut_socket_common.c b/libraries/wutsocket/wut_socket_common.c index 686b087..c0ac2ae 100644 --- a/libraries/wutsocket/wut_socket_common.c +++ b/libraries/wutsocket/wut_socket_common.c @@ -104,12 +104,13 @@ __init_wut_socket() { socket_lib_init(); ACInitialize(); - ACConnect(); + ACConnectAsync(); } void __attribute__((weak)) __fini_wut_socket() { + ACClose(); ACFinalize(); socket_lib_finish(); }