summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings_Network.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-02-13 18:31:54 +0100
committerMattes D <github@xoft.cz>2015-02-13 18:31:54 +0100
commitb8bf795dd1701a32075950a6ea98a16eacb9edc9 (patch)
treef1ebfe9934632f1ccb8f2a7a36b4c1598f73a55f /src/Bindings/ManualBindings_Network.cpp
parentPolarSSL++: Fixed debugging output. (diff)
downloadcuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.tar
cuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.tar.gz
cuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.tar.bz2
cuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.tar.lz
cuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.tar.xz
cuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.tar.zst
cuberite-b8bf795dd1701a32075950a6ea98a16eacb9edc9.zip
Diffstat (limited to 'src/Bindings/ManualBindings_Network.cpp')
-rw-r--r--src/Bindings/ManualBindings_Network.cpp96
1 files changed, 83 insertions, 13 deletions
diff --git a/src/Bindings/ManualBindings_Network.cpp b/src/Bindings/ManualBindings_Network.cpp
index ff0f3568c..4a6b7bc0e 100644
--- a/src/Bindings/ManualBindings_Network.cpp
+++ b/src/Bindings/ManualBindings_Network.cpp
@@ -214,17 +214,16 @@ static int tolua_cNetwork_Listen(lua_State * L)
////////////////////////////////////////////////////////////////////////////////
// cTCPLink bindings (routed through cLuaTCPLink):
-/** Binds cLuaTCPLink::Send */
-static int tolua_cTCPLink_Send(lua_State * L)
+/** Binds cLuaTCPLink::Close */
+static int tolua_cTCPLink_Close(lua_State * L)
{
// Function signature:
- // LinkInstance:Send(DataString)
+ // LinkInstance:Close()
cLuaState S(L);
if (
!S.CheckParamUserType(1, "cTCPLink") ||
- !S.CheckParamString(2) ||
- !S.CheckParamEnd(3)
+ !S.CheckParamEnd(2)
)
{
return 0;
@@ -234,18 +233,14 @@ static int tolua_cTCPLink_Send(lua_State * L)
cLuaTCPLink * Link;
if (lua_isnil(L, 1))
{
- LOGWARNING("cTCPLink:Send(): invalid link object. Stack trace:");
+ LOGWARNING("cTCPLink:Close(): invalid link object. Stack trace:");
S.LogStackTrace();
return 0;
}
Link = *static_cast<cLuaTCPLink **>(lua_touserdata(L, 1));
- // Get the data to send:
- AString Data;
- S.GetStackValues(2, Data);
-
- // Send the data:
- Link->Send(Data);
+ // CLose the link:
+ Link->Close();
return 0;
}
@@ -389,6 +384,79 @@ static int tolua_cTCPLink_GetRemotePort(lua_State * L)
+/** Binds cLuaTCPLink::Send */
+static int tolua_cTCPLink_Send(lua_State * L)
+{
+ // Function signature:
+ // LinkInstance:Send(DataString)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserType(1, "cTCPLink") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the link:
+ cLuaTCPLink * Link;
+ if (lua_isnil(L, 1))
+ {
+ LOGWARNING("cTCPLink:Send(): invalid link object. Stack trace:");
+ S.LogStackTrace();
+ return 0;
+ }
+ Link = *static_cast<cLuaTCPLink **>(lua_touserdata(L, 1));
+
+ // Get the data to send:
+ AString Data;
+ S.GetStackValues(2, Data);
+
+ // Send the data:
+ Link->Send(Data);
+ return 0;
+}
+
+
+
+
+
+/** Binds cLuaTCPLink::Shutdown */
+static int tolua_cTCPLink_Shutdown(lua_State * L)
+{
+ // Function signature:
+ // LinkInstance:Shutdown()
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserType(1, "cTCPLink") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get the link:
+ cLuaTCPLink * Link;
+ if (lua_isnil(L, 1))
+ {
+ LOGWARNING("cTCPLink:Shutdown(): invalid link object. Stack trace:");
+ S.LogStackTrace();
+ return 0;
+ }
+ Link = *static_cast<cLuaTCPLink **>(lua_touserdata(L, 1));
+
+ // Shutdown the link:
+ Link->Shutdown();
+ return 0;
+}
+
+
+
+
+
/** Binds cLuaTCPLink::StartTLSClient */
static int tolua_cTCPLink_StartTLSClient(lua_State * L)
{
@@ -540,11 +608,13 @@ void ManualBindings::BindNetwork(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cTCPLink");
- tolua_function(tolua_S, "Send", tolua_cTCPLink_Send);
+ 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_endmodule(tolua_S);