summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings_Network.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings/ManualBindings_Network.cpp')
-rw-r--r--src/Bindings/ManualBindings_Network.cpp342
1 files changed, 139 insertions, 203 deletions
diff --git a/src/Bindings/ManualBindings_Network.cpp b/src/Bindings/ManualBindings_Network.cpp
index c184821e9..de3c258b9 100644
--- a/src/Bindings/ManualBindings_Network.cpp
+++ b/src/Bindings/ManualBindings_Network.cpp
@@ -28,13 +28,8 @@ static int tolua_cNetwork_Connect(lua_State * L)
// cNetwork:Connect(Host, Port, Callbacks) -> bool
cLuaState S(L);
- if (
- !S.CheckParamStaticSelf("cNetwork") ||
- !S.CheckParamString(2) ||
- !S.CheckParamNumber(3) ||
- !S.CheckParamTable(4) ||
- !S.CheckParamEnd(5)
- )
+ if (!S.CheckParamStaticSelf("cNetwork") || !S.CheckParamString(2) || !S.CheckParamNumber(3) ||
+ !S.CheckParamTable(4) || !S.CheckParamEnd(5))
{
return 0;
}
@@ -76,12 +71,7 @@ static int tolua_cNetwork_CreateUDPEndpoint(lua_State * L)
// cNetwork:CreateUDPEndpoint(Port, Callbacks) -> cUDPEndpoint
cLuaState S(L);
- if (
- !S.CheckParamStaticSelf("cNetwork") ||
- !S.CheckParamNumber(2) ||
- !S.CheckParamTable(3) ||
- !S.CheckParamEnd(4)
- )
+ if (!S.CheckParamStaticSelf("cNetwork") || !S.CheckParamNumber(2) || !S.CheckParamTable(3) || !S.CheckParamEnd(4))
{
return 0;
}
@@ -125,10 +115,7 @@ static int tolua_cNetwork_EnumLocalIPAddresses(lua_State * L)
// cNetwork:EnumLocalIPAddresses() -> {string, ...}
cLuaState S(L);
- if (
- !S.CheckParamStaticSelf("cNetwork") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamStaticSelf("cNetwork") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -149,12 +136,7 @@ static int tolua_cNetwork_HostnameToIP(lua_State * L)
// cNetwork:HostnameToIP(Host, Callbacks) -> bool
cLuaState S(L);
- if (
- !S.CheckParamStaticSelf("cNetwork") ||
- !S.CheckParamString(2) ||
- !S.CheckParamTable(3) ||
- !S.CheckParamEnd(4)
- )
+ if (!S.CheckParamStaticSelf("cNetwork") || !S.CheckParamString(2) || !S.CheckParamTable(3) || !S.CheckParamEnd(4))
{
return 0;
}
@@ -185,12 +167,7 @@ static int tolua_cNetwork_IPToHostname(lua_State * L)
// cNetwork:IPToHostname(IP, Callbacks) -> bool
cLuaState S(L);
- if (
- !S.CheckParamStaticSelf("cNetwork") ||
- !S.CheckParamString(2) ||
- !S.CheckParamTable(3) ||
- !S.CheckParamEnd(4)
- )
+ if (!S.CheckParamStaticSelf("cNetwork") || !S.CheckParamString(2) || !S.CheckParamTable(3) || !S.CheckParamEnd(4))
{
return 0;
}
@@ -221,12 +198,7 @@ static int tolua_cNetwork_Listen(lua_State * L)
// cNetwork:Listen(Port, Callbacks) -> cServerHandle
cLuaState S(L);
- if (
- !S.CheckParamStaticSelf("cNetwork") ||
- !S.CheckParamNumber(2) ||
- !S.CheckParamTable(3) ||
- !S.CheckParamEnd(4)
- )
+ if (!S.CheckParamStaticSelf("cNetwork") || !S.CheckParamNumber(2) || !S.CheckParamTable(3) || !S.CheckParamEnd(4))
{
return 0;
}
@@ -289,10 +261,7 @@ static int tolua_cServerHandle_Close(lua_State * L)
// ServerInstance:Close()
cLuaState S(L);
- if (
- !S.CheckParamSelf("cServerHandle") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cServerHandle") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -317,10 +286,7 @@ static int tolua_cServerHandle_IsListening(lua_State * L)
// ServerInstance:IsListening() -> bool
cLuaState S(L);
- if (
- !S.CheckParamSelf("cServerHandle") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cServerHandle") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -348,10 +314,7 @@ static int tolua_cTCPLink_Close(lua_State * L)
// LinkInstance:Close()
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -376,10 +339,7 @@ static int tolua_cTCPLink_GetLocalIP(lua_State * L)
// LinkInstance:GetLocalIP() -> string
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -404,10 +364,7 @@ static int tolua_cTCPLink_GetLocalPort(lua_State * L)
// LinkInstance:GetLocalPort() -> number
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -432,10 +389,7 @@ static int tolua_cTCPLink_GetRemoteIP(lua_State * L)
// LinkInstance:GetRemoteIP() -> string
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -460,10 +414,7 @@ static int tolua_cTCPLink_GetRemotePort(lua_State * L)
// LinkInstance:GetRemotePort() -> number
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -488,11 +439,7 @@ static int tolua_cTCPLink_Send(lua_State * L)
// LinkInstance:Send(DataString)
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamString(2) ||
- !S.CheckParamEnd(3)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamString(2) || !S.CheckParamEnd(3))
{
return 0;
}
@@ -521,10 +468,7 @@ static int tolua_cTCPLink_Shutdown(lua_State * L)
// LinkInstance:Shutdown()
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -559,16 +503,27 @@ static int tolua_cTCPLink_StartTLSClient(lua_State * L)
// Read the (optional) params:
AString OwnCert, OwnPrivKey, OwnPrivKeyPassword, TrustedRootCAs;
- S.GetStackValues(2, OwnCert, OwnPrivKey, OwnPrivKeyPassword, cLuaState::cOptionalParam<std::string>(TrustedRootCAs));
+ S.GetStackValues(
+ 2,
+ OwnCert,
+ OwnPrivKey,
+ OwnPrivKeyPassword,
+ cLuaState::cOptionalParam<std::string>(TrustedRootCAs)
+ );
// Start the TLS handshake:
AString res = Link->StartTLSClient(OwnCert, OwnPrivKey, OwnPrivKeyPassword, TrustedRootCAs);
if (!res.empty())
{
- S.Push(cLuaState::Nil, fmt::format(
- FMT_STRING("Cannot start TLS on link to {}:{}: {}"),
- Link->GetRemoteIP(), Link->GetRemotePort(), res
- ));
+ S.Push(
+ cLuaState::Nil,
+ fmt::format(
+ FMT_STRING("Cannot start TLS on link to {}:{}: {}"),
+ Link->GetRemoteIP(),
+ Link->GetRemotePort(),
+ res
+ )
+ );
return 2;
}
return 1;
@@ -585,12 +540,9 @@ static int tolua_cTCPLink_StartTLSServer(lua_State * L)
// LinkInstance:StartTLSServer(OwnCert, OwnPrivKey, OwnPrivKeyPassword, StartTLSData) -> [true] or [nil, ErrMsg]
cLuaState S(L);
- if (
- !S.CheckParamSelf("cTCPLink") ||
- !S.CheckParamString(2, 4) ||
+ if (!S.CheckParamSelf("cTCPLink") || !S.CheckParamString(2, 4) ||
// Param 5 is optional, don't check
- !S.CheckParamEnd(6)
- )
+ !S.CheckParamEnd(6))
{
return 0;
}
@@ -607,10 +559,15 @@ static int tolua_cTCPLink_StartTLSServer(lua_State * L)
AString res = Link->StartTLSServer(OwnCert, OwnPrivKey, OwnPrivKeyPassword, StartTLSData);
if (!res.empty())
{
- S.Push(cLuaState::Nil, fmt::format(
- FMT_STRING("Cannot start TLS on link to {}:{}: {}"),
- Link->GetRemoteIP(), Link->GetRemotePort(), res
- ));
+ S.Push(
+ cLuaState::Nil,
+ fmt::format(
+ FMT_STRING("Cannot start TLS on link to {}:{}: {}"),
+ Link->GetRemoteIP(),
+ Link->GetRemotePort(),
+ res
+ )
+ );
return 2;
}
S.Push(true);
@@ -645,10 +602,7 @@ static int tolua_cUDPEndpoint_Close(lua_State * L)
// EndpointInstance:Close()
cLuaState S(L);
- if (
- !S.CheckParamSelf("cUDPEndpoint") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cUDPEndpoint") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -673,10 +627,7 @@ static int tolua_cUDPEndpoint_EnableBroadcasts(lua_State * L)
// EndpointInstance:EnableBroadcasts()
cLuaState S(L);
- if (
- !S.CheckParamSelf("cUDPEndpoint") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cUDPEndpoint") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -701,10 +652,7 @@ static int tolua_cUDPEndpoint_GetPort(lua_State * L)
// Endpoint:GetPort() -> number
cLuaState S(L);
- if (
- !S.CheckParamSelf("cUDPEndpoint") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cUDPEndpoint") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -729,10 +677,7 @@ static int tolua_cUDPEndpoint_IsOpen(lua_State * L)
// Endpoint:IsOpen() -> bool
cLuaState S(L);
- if (
- !S.CheckParamSelf("cUDPEndpoint") ||
- !S.CheckParamEnd(2)
- )
+ if (!S.CheckParamSelf("cUDPEndpoint") || !S.CheckParamEnd(2))
{
return 0;
}
@@ -757,12 +702,7 @@ static int tolua_cUDPEndpoint_Send(lua_State * L)
// Endpoint:Send(DataString)
cLuaState S(L);
- if (
- !S.CheckParamSelf("cUDPEndpoint") ||
- !S.CheckParamString(2, 3) ||
- !S.CheckParamNumber(4) ||
- !S.CheckParamEnd(5)
- )
+ if (!S.CheckParamSelf("cUDPEndpoint") || !S.CheckParamString(2, 3) || !S.CheckParamNumber(4) || !S.CheckParamEnd(5))
{
return 0;
}
@@ -779,7 +719,8 @@ static int tolua_cUDPEndpoint_Send(lua_State * L)
// Check the port:
if ((remotePort < 0) || (remotePort > USHRT_MAX))
{
- return S.ApiParamError(fmt::format(FMT_STRING("Port number out of range (got {}, range 0 - 65535)"), remotePort));
+ return S.ApiParamError(fmt::format(FMT_STRING("Port number out of range (got {}, range 0 - 65535)"), remotePort)
+ );
}
// Send the data:
@@ -793,12 +734,11 @@ static int tolua_cUDPEndpoint_Send(lua_State * L)
/** Used when the cUrlClient Lua request wants all the callbacks.
Maps each callback onto a Lua function callback in the callback table. */
-class cFullUrlClientCallbacks:
- public cUrlClient::cCallbacks
+class cFullUrlClientCallbacks : public cUrlClient::cCallbacks
{
-public:
+ public:
/** Creates a new instance bound to the specified table of callbacks. */
- cFullUrlClientCallbacks(cLuaState::cTableRefPtr && a_Callbacks):
+ cFullUrlClientCallbacks(cLuaState::cTableRefPtr && a_Callbacks) :
m_Callbacks(std::move(a_Callbacks))
{
}
@@ -814,23 +754,18 @@ public:
virtual bool OnCertificateReceived() override
{
- // TODO: The received cert needs proper type specification from the underlying cUrlClient framework and in the Lua engine as well
+ // TODO: The received cert needs proper type specification from the underlying cUrlClient framework and in the
+ // Lua engine as well
bool res = true;
m_Callbacks->CallTableFnWithSelf("OnCertificateReceived", cLuaState::Return, res);
return res;
}
- virtual void OnTlsHandshakeCompleted() override
- {
- m_Callbacks->CallTableFnWithSelf("OnTlsHandshakeCompleted");
- }
+ virtual void OnTlsHandshakeCompleted() override { m_Callbacks->CallTableFnWithSelf("OnTlsHandshakeCompleted"); }
- virtual void OnRequestSent() override
- {
- m_Callbacks->CallTableFnWithSelf("OnRequestSent");
- }
+ virtual void OnRequestSent() override { m_Callbacks->CallTableFnWithSelf("OnRequestSent"); }
virtual void OnStatusLine(const AString & a_HttpVersion, int a_StatusCode, const AString & a_Rest) override
@@ -846,10 +781,7 @@ public:
}
- virtual void OnHeadersFinished() override
- {
- m_Callbacks->CallTableFnWithSelf("OnHeadersFinished", m_Headers);
- }
+ virtual void OnHeadersFinished() override { m_Callbacks->CallTableFnWithSelf("OnHeadersFinished", m_Headers); }
virtual void OnBodyData(const void * a_Data, size_t a_Size) override
@@ -858,10 +790,7 @@ public:
}
- virtual void OnBodyFinished() override
- {
- m_Callbacks->CallTableFnWithSelf("OnBodyFinished");
- }
+ virtual void OnBodyFinished() override { m_Callbacks->CallTableFnWithSelf("OnBodyFinished"); }
virtual void OnError(const AString & a_ErrorMsg) override
@@ -876,7 +805,7 @@ public:
}
-protected:
+ protected:
/** The Lua table containing the callbacks. */
cLuaState::cTableRefPtr m_Callbacks;
@@ -894,21 +823,17 @@ callback("BodyContents", {headers})
callback(nil, "ErrorMessage")
Accumulates the body contents into a single string until the body is finished.
Accumulates all HTTP headers into an AStringMap. */
-class cSimpleUrlClientCallbacks:
- public cUrlClient::cCallbacks
+class cSimpleUrlClientCallbacks : public cUrlClient::cCallbacks
{
-public:
+ public:
/** Creates a new instance that uses the specified callback to report when request finishes. */
- cSimpleUrlClientCallbacks(cLuaState::cCallbackPtr && a_Callback):
+ cSimpleUrlClientCallbacks(cLuaState::cCallbackPtr && a_Callback) :
m_Callback(std::move(a_Callback))
{
}
- virtual void OnHeader(const AString & a_Key, const AString & a_Value) override
- {
- m_Headers[a_Key] = a_Value;
- }
+ virtual void OnHeader(const AString & a_Key, const AString & a_Value) override { m_Headers[a_Key] = a_Value; }
virtual void OnBodyData(const void * a_Data, size_t a_Size) override
@@ -917,20 +842,13 @@ public:
}
- virtual void OnBodyFinished() override
- {
- m_Callback->Call(m_ResponseBody, m_Headers);
- }
-
+ virtual void OnBodyFinished() override { m_Callback->Call(m_ResponseBody, m_Headers); }
- virtual void OnError(const AString & a_ErrorMsg) override
- {
- m_Callback->Call(cLuaState::Nil, a_ErrorMsg);
- }
+ virtual void OnError(const AString & a_ErrorMsg) override { m_Callback->Call(cLuaState::Nil, a_ErrorMsg); }
-protected:
+ protected:
/** The callback to call when the request finishes. */
cLuaState::cCallbackPtr m_Callback;
@@ -971,7 +889,9 @@ static int tolua_cUrlClient_Request_Common(lua_State * a_LuaState, const AString
{
if (!L.GetStackValue(a_UrlStackIdx + 1, callbacks))
{
- return L.ApiParamError(fmt::format(FMT_STRING("Cannot read the CallbacksTable parameter at idx {}"), a_UrlStackIdx + 1));
+ return L.ApiParamError(
+ fmt::format(FMT_STRING("Cannot read the CallbacksTable parameter at idx {}"), a_UrlStackIdx + 1)
+ );
}
urlClientCallbacks = std::make_unique<cFullUrlClientCallbacks>(std::move(callbacks));
}
@@ -979,7 +899,9 @@ static int tolua_cUrlClient_Request_Common(lua_State * a_LuaState, const AString
{
if (!L.GetStackValue(a_UrlStackIdx + 1, onCompleteBodyCallback))
{
- return L.ApiParamError(fmt::format(FMT_STRING("Cannot read the CallbackFn parameter at idx {}"), a_UrlStackIdx + 1));
+ return L.ApiParamError(
+ fmt::format(FMT_STRING("Cannot read the CallbackFn parameter at idx {}"), a_UrlStackIdx + 1)
+ );
}
urlClientCallbacks = std::make_unique<cSimpleUrlClientCallbacks>(std::move(onCompleteBodyCallback));
}
@@ -987,19 +909,34 @@ static int tolua_cUrlClient_Request_Common(lua_State * a_LuaState, const AString
{
L.ApiParamError(fmt::format(
FMT_STRING("Invalid Callbacks parameter at {}, expected a table or function, got {}"),
- a_UrlStackIdx + 1, L.GetTypeText(a_UrlStackIdx + 1)
+ a_UrlStackIdx + 1,
+ L.GetTypeText(a_UrlStackIdx + 1)
));
}
- if (!L.GetStackValues(a_UrlStackIdx + 2, cLuaState::cOptionalParam<AStringMap>(headers), cLuaState::cOptionalParam<AString>(requestBody), cLuaState::cOptionalParam<AStringMap>(options)))
+ if (!L.GetStackValues(
+ a_UrlStackIdx + 2,
+ cLuaState::cOptionalParam<AStringMap>(headers),
+ cLuaState::cOptionalParam<AString>(requestBody),
+ cLuaState::cOptionalParam<AStringMap>(options)
+ ))
{
L.ApiParamError(fmt::format(
FMT_STRING("Cannot read the Header, Body or Options parameter at idx {}, {}, {}."),
- a_UrlStackIdx + 2, a_UrlStackIdx + 3, a_UrlStackIdx + 4
+ a_UrlStackIdx + 2,
+ a_UrlStackIdx + 3,
+ a_UrlStackIdx + 4
));
}
// Make the request:
- auto res = cUrlClient::Request(a_Method, url, std::move(urlClientCallbacks), std::move(headers), std::move(requestBody), std::move(options));
+ auto res = cUrlClient::Request(
+ a_Method,
+ url,
+ std::move(urlClientCallbacks),
+ std::move(headers),
+ std::move(requestBody),
+ std::move(options)
+ );
if (!res.first)
{
L.Push(false);
@@ -1018,8 +955,9 @@ static int tolua_cUrlClient_Request_Common(lua_State * a_LuaState, const AString
static int tolua_cUrlClient_Delete(lua_State * a_LuaState)
{
/* Function signatures:
- cUrlClient:Delete(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
- cUrlClient:Delete(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
+ cUrlClient:Delete(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false
+ + string cUrlClient:Delete(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) ->
+ true / false + string
*/
return tolua_cUrlClient_Request_Common(a_LuaState, "DELETE", 2);
@@ -1033,8 +971,9 @@ static int tolua_cUrlClient_Delete(lua_State * a_LuaState)
static int tolua_cUrlClient_Get(lua_State * a_LuaState)
{
/* Function signatures:
- cUrlClient:Get(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
- cUrlClient:Get(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
+ cUrlClient:Get(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false +
+ string cUrlClient:Get(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true
+ / false + string
*/
return tolua_cUrlClient_Request_Common(a_LuaState, "GET", 2);
@@ -1048,8 +987,9 @@ static int tolua_cUrlClient_Get(lua_State * a_LuaState)
static int tolua_cUrlClient_Post(lua_State * a_LuaState)
{
/* Function signatures:
- cUrlClient:Post(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
- cUrlClient:Post(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
+ cUrlClient:Post(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false +
+ string cUrlClient:Post(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true
+ / false + string
*/
return tolua_cUrlClient_Request_Common(a_LuaState, "POST", 2);
@@ -1063,8 +1003,9 @@ static int tolua_cUrlClient_Post(lua_State * a_LuaState)
static int tolua_cUrlClient_Put(lua_State * a_LuaState)
{
/* Function signatures:
- cUrlClient:Put(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
- cUrlClient:Put(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
+ cUrlClient:Put(URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false +
+ string cUrlClient:Put(URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true
+ / false + string
*/
return tolua_cUrlClient_Request_Common(a_LuaState, "PUT", 2);
@@ -1078,15 +1019,14 @@ static int tolua_cUrlClient_Put(lua_State * a_LuaState)
static int tolua_cUrlClient_Request(lua_State * a_LuaState)
{
/* Function signatures:
- cUrlClient:Request(Method, URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
- cUrlClient:Request(Method, URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true / false + string
+ cUrlClient:Request(Method, URL, {CallbacksFnTable}, [{HeadersMapTable}], [RequestBody], [{OptionsMapTable}]) -> true
+ / false + string cUrlClient:Request(Method, URL, OnCompleteBodyCallback, [{HeadersMapTable}], [RequestBody],
+ [{OptionsMapTable}]) -> true / false + string
*/
// Check that the Method param is a string:
cLuaState L(a_LuaState);
- if (
- !L.CheckParamStaticSelf("cUrlClient") ||
- !L.CheckParamString(2))
+ if (!L.CheckParamStaticSelf("cUrlClient") || !L.CheckParamString(2))
{
return 0;
}
@@ -1115,56 +1055,52 @@ void cManualBindings::BindNetwork(lua_State * tolua_S)
tolua_usertype(tolua_S, "cTCPLink");
tolua_usertype(tolua_S, "cUDPEndpoint");
tolua_usertype(tolua_S, "cUrlClient");
- tolua_cclass(tolua_S, "cNetwork", "cNetwork", "", nullptr);
+ tolua_cclass(tolua_S, "cNetwork", "cNetwork", "", nullptr);
tolua_cclass(tolua_S, "cServerHandle", "cServerHandle", "", tolua_collect_cServerHandle);
- tolua_cclass(tolua_S, "cTCPLink", "cTCPLink", "", nullptr);
- tolua_cclass(tolua_S, "cUDPEndpoint", "cUDPEndpoint", "", tolua_collect_cUDPEndpoint);
- tolua_cclass(tolua_S, "cUrlClient", "cUrlClient", "", nullptr);
+ tolua_cclass(tolua_S, "cTCPLink", "cTCPLink", "", nullptr);
+ tolua_cclass(tolua_S, "cUDPEndpoint", "cUDPEndpoint", "", tolua_collect_cUDPEndpoint);
+ tolua_cclass(tolua_S, "cUrlClient", "cUrlClient", "", nullptr);
// Fill in the functions (alpha-sorted):
tolua_beginmodule(tolua_S, "cNetwork");
- tolua_function(tolua_S, "Connect", tolua_cNetwork_Connect);
- tolua_function(tolua_S, "CreateUDPEndpoint", tolua_cNetwork_CreateUDPEndpoint);
- tolua_function(tolua_S, "EnumLocalIPAddresses", tolua_cNetwork_EnumLocalIPAddresses);
- tolua_function(tolua_S, "HostnameToIP", tolua_cNetwork_HostnameToIP);
- tolua_function(tolua_S, "IPToHostname", tolua_cNetwork_IPToHostname);
- tolua_function(tolua_S, "Listen", tolua_cNetwork_Listen);
+ tolua_function(tolua_S, "Connect", tolua_cNetwork_Connect);
+ tolua_function(tolua_S, "CreateUDPEndpoint", tolua_cNetwork_CreateUDPEndpoint);
+ tolua_function(tolua_S, "EnumLocalIPAddresses", tolua_cNetwork_EnumLocalIPAddresses);
+ tolua_function(tolua_S, "HostnameToIP", tolua_cNetwork_HostnameToIP);
+ tolua_function(tolua_S, "IPToHostname", tolua_cNetwork_IPToHostname);
+ tolua_function(tolua_S, "Listen", tolua_cNetwork_Listen);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cServerHandle");
- tolua_function(tolua_S, "Close", tolua_cServerHandle_Close);
- tolua_function(tolua_S, "IsListening", tolua_cServerHandle_IsListening);
+ tolua_function(tolua_S, "Close", tolua_cServerHandle_Close);
+ tolua_function(tolua_S, "IsListening", tolua_cServerHandle_IsListening);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cTCPLink");
- tolua_function(tolua_S, "Close", tolua_cTCPLink_Close);
- tolua_function(tolua_S, "GetLocalIP", tolua_cTCPLink_GetLocalIP);
- tolua_function(tolua_S, "GetLocalPort", tolua_cTCPLink_GetLocalPort);
- tolua_function(tolua_S, "GetRemoteIP", tolua_cTCPLink_GetRemoteIP);
- tolua_function(tolua_S, "GetRemotePort", tolua_cTCPLink_GetRemotePort);
- tolua_function(tolua_S, "Send", tolua_cTCPLink_Send);
- tolua_function(tolua_S, "Shutdown", tolua_cTCPLink_Shutdown);
- tolua_function(tolua_S, "StartTLSClient", tolua_cTCPLink_StartTLSClient);
- tolua_function(tolua_S, "StartTLSServer", tolua_cTCPLink_StartTLSServer);
+ tolua_function(tolua_S, "Close", tolua_cTCPLink_Close);
+ tolua_function(tolua_S, "GetLocalIP", tolua_cTCPLink_GetLocalIP);
+ tolua_function(tolua_S, "GetLocalPort", tolua_cTCPLink_GetLocalPort);
+ tolua_function(tolua_S, "GetRemoteIP", tolua_cTCPLink_GetRemoteIP);
+ tolua_function(tolua_S, "GetRemotePort", tolua_cTCPLink_GetRemotePort);
+ tolua_function(tolua_S, "Send", tolua_cTCPLink_Send);
+ tolua_function(tolua_S, "Shutdown", tolua_cTCPLink_Shutdown);
+ tolua_function(tolua_S, "StartTLSClient", tolua_cTCPLink_StartTLSClient);
+ tolua_function(tolua_S, "StartTLSServer", tolua_cTCPLink_StartTLSServer);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cUDPEndpoint");
- tolua_function(tolua_S, "Close", tolua_cUDPEndpoint_Close);
- tolua_function(tolua_S, "EnableBroadcasts", tolua_cUDPEndpoint_EnableBroadcasts);
- tolua_function(tolua_S, "GetPort", tolua_cUDPEndpoint_GetPort);
- tolua_function(tolua_S, "IsOpen", tolua_cUDPEndpoint_IsOpen);
- tolua_function(tolua_S, "Send", tolua_cUDPEndpoint_Send);
+ tolua_function(tolua_S, "Close", tolua_cUDPEndpoint_Close);
+ tolua_function(tolua_S, "EnableBroadcasts", tolua_cUDPEndpoint_EnableBroadcasts);
+ tolua_function(tolua_S, "GetPort", tolua_cUDPEndpoint_GetPort);
+ tolua_function(tolua_S, "IsOpen", tolua_cUDPEndpoint_IsOpen);
+ tolua_function(tolua_S, "Send", tolua_cUDPEndpoint_Send);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cUrlClient");
- tolua_function(tolua_S, "Delete", tolua_cUrlClient_Delete);
- tolua_function(tolua_S, "Get", tolua_cUrlClient_Get);
- tolua_function(tolua_S, "Post", tolua_cUrlClient_Post);
- tolua_function(tolua_S, "Put", tolua_cUrlClient_Put);
- tolua_function(tolua_S, "Request", tolua_cUrlClient_Request);
+ tolua_function(tolua_S, "Delete", tolua_cUrlClient_Delete);
+ tolua_function(tolua_S, "Get", tolua_cUrlClient_Get);
+ tolua_function(tolua_S, "Post", tolua_cUrlClient_Post);
+ tolua_function(tolua_S, "Put", tolua_cUrlClient_Put);
+ tolua_function(tolua_S, "Request", tolua_cUrlClient_Request);
tolua_endmodule(tolua_S);
}
-
-
-
-