diff --git a/examples/async-client.c b/examples/async-client.c index aa22e30..5a7738f 100644 --- a/examples/async-client.c +++ b/examples/async-client.c @@ -194,7 +194,7 @@ int main(int argc, char* argv[]) endpt.bUnix = args.bUnix; endpt.bTLS = args.bSSL; - if (XAPI_Connect(&api, &endpt) < 0) + if (XAPI_AddEndpoint(&api, &endpt, XAPI_CLIENT) < 0) { XAPI_Destroy(&api); return XSTDERR; diff --git a/examples/async-server.c b/examples/async-server.c index 4fbd56e..9ae5b4e 100644 --- a/examples/async-server.c +++ b/examples/async-server.c @@ -231,7 +231,7 @@ int main(int argc, char* argv[]) #endif } - if (XAPI_Listen(&api, &endpt) < 0) + if (XAPI_AddEndpoint(&api, &endpt, XAPI_SERVER) < 0) { XAPI_Destroy(&api); return XSTDERR; diff --git a/examples/http-server.c b/examples/http-server.c index afb7313..50bc213 100644 --- a/examples/http-server.c +++ b/examples/http-server.c @@ -273,7 +273,7 @@ int main(int argc, char* argv[]) #endif } - if (XAPI_Listen(&api, &endpt) < 0) + if (XAPI_AddEndpoint(&api, &endpt, XAPI_SERVER) < 0) { XAPI_Destroy(&api); return XSTDERR; diff --git a/examples/ws-client.c b/examples/ws-client.c index 6047cf5..c107b5b 100644 --- a/examples/ws-client.c +++ b/examples/ws-client.c @@ -271,7 +271,7 @@ int main(int argc, char* argv[]) session_data_t sessData; endpt.pSessionData = &sessData; - if (XAPI_Connect(&api, &endpt) < 0) + if (XAPI_AddEndpoint(&api, &endpt, XAPI_CLIENT) < 0) { XAPI_Destroy(&api); return XSTDERR; diff --git a/examples/ws-server.c b/examples/ws-server.c index b6c2750..c81574e 100644 --- a/examples/ws-server.c +++ b/examples/ws-server.c @@ -354,7 +354,7 @@ int main(int argc, char* argv[]) #endif } - if (XAPI_Listen(&api, &endpt) < 0) + if (XAPI_AddEndpoint(&api, &endpt, XAPI_SERVER) < 0) { XAPI_Destroy(&api); return XSTDERR; diff --git a/src/net/api.c b/src/net/api.c index fe1e172..8c1d019 100644 --- a/src/net/api.c +++ b/src/net/api.c @@ -1324,3 +1324,15 @@ XSTATUS XAPI_Connect(xapi_t *pApi, xapi_endpoint_t *pEndpt) return XSTDOK; } + +XSTATUS XAPI_AddEndpoint(xapi_t *pApi, xapi_endpoint_t *pEndpt, xapi_role_t eRole) +{ + switch (eRole) + { + case XAPI_SERVER: return XAPI_Listen(pApi, pEndpt); + case XAPI_CLIENT: return XAPI_Connect(pApi, pEndpt); + default: break; + } + + return XSTDERR; +} \ No newline at end of file diff --git a/src/net/api.h b/src/net/api.h index 644805f..33e8f89 100644 --- a/src/net/api.h +++ b/src/net/api.h @@ -174,6 +174,7 @@ XSTATUS XAPI_AuthorizeHTTP(xapi_data_t *pApiData, const char *pToken, const char void XAPI_InitEndpoint(xapi_endpoint_t *pEndpt); XSTATUS XAPI_Listen(xapi_t *pApi, xapi_endpoint_t *pEndpt); XSTATUS XAPI_Connect(xapi_t *pApi, xapi_endpoint_t *pEndpt); +XSTATUS XAPI_AddEndpoint(xapi_t *pApi, xapi_endpoint_t *pEndpt, xapi_role_t eRole); xevent_status_t XAPI_Service(xapi_t *pApi, int nTimeoutMs); diff --git a/tools/xtop.c b/tools/xtop.c index ec69f98..051a95a 100644 --- a/tools/xtop.c +++ b/tools/xtop.c @@ -1567,7 +1567,7 @@ int XTOPApp_ServerMode(xtop_args_t *pArgs, xtop_stats_t *pStats) endpt.pAddr = pArgs->sAddr; endpt.nPort = pArgs->nPort; - if (XAPI_Listen(&api, &endpt) < 0) + if (XAPI_AddEndpoint(&api, &endpt, XAPI_SERVER) < 0) { XAPI_Destroy(&api); return XSTDERR;