mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +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
|
// Socket
|
||||||
pushFunction(L_p, "socketConnect", socketConnect);
|
pushFunction(L_p, "socketConnect", socketConnect);
|
||||||
|
pushFunction(L_p, "socketDisconnect", socketDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaEngineNetwork::pushClass(LuaEngine *luaEngine)
|
void LuaEngineNetwork::pushClass(LuaEngine *luaEngine)
|
||||||
|
@ -67,6 +68,22 @@ int LuaEngineNetwork::socketConnect(lua_State *L_p)
|
||||||
return 0;
|
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 LuaEngineNetwork::nameForPointer(void *pointer)
|
||||||
{
|
{
|
||||||
QString nameStorage;
|
QString nameStorage;
|
||||||
|
|
|
@ -30,6 +30,7 @@ public:
|
||||||
static void pushClass(LuaEngine *luaEngine);
|
static void pushClass(LuaEngine *luaEngine);
|
||||||
static int createLocalSocket(lua_State *L_p);
|
static int createLocalSocket(lua_State *L_p);
|
||||||
static int socketConnect(lua_State *L_p);
|
static int socketConnect(lua_State *L_p);
|
||||||
|
static int socketDisconnect(lua_State *L_p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
|
|
Loading…
Reference in a new issue