mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-05 05:26:55 +01:00
add socketDisconnect
This commit is contained in:
parent
188dd0c9cb
commit
64a3508441
2 changed files with 18 additions and 0 deletions
|
@ -26,6 +26,7 @@ void LuaEngineNetwork::pushClass(lua_State *L_p)
|
|||
|
||||
// Socket
|
||||
pushFunction(L_p, "socketConnect", socketConnect);
|
||||
pushFunction(L_p, "socketDisconnect", socketDisconnect);
|
||||
}
|
||||
|
||||
void LuaEngineNetwork::pushClass(LuaEngine *luaEngine)
|
||||
|
@ -67,6 +68,22 @@ int LuaEngineNetwork::socketConnect(lua_State *L_p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LuaEngineNetwork::socketDisconnect(lua_State *L_p)
|
||||
{
|
||||
if (getArgumentCount(L_p) >= 1) {
|
||||
void *pointer = getPointer(L_p, 1);
|
||||
if (pointer != NULL) {
|
||||
if (((QObject*)pointer)->inherits("QLocalSocket")) {
|
||||
((QLocalSocket*)pointer)->disconnectFromServer();
|
||||
}
|
||||
else if (((QObject*)pointer)->inherits("QAbstractSocket")) {
|
||||
((QAbstractSocket*)pointer)->disconnectFromHost();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString LuaEngineNetwork::nameForPointer(void *pointer)
|
||||
{
|
||||
QString nameStorage;
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
static void pushClass(LuaEngine *luaEngine);
|
||||
static int createLocalSocket(lua_State *L_p);
|
||||
static int socketConnect(lua_State *L_p);
|
||||
static int socketDisconnect(lua_State *L_p);
|
||||
|
||||
private:
|
||||
lua_State *L;
|
||||
|
|
Loading…
Reference in a new issue