diff options
Diffstat (limited to 'Sluift/client.cpp')
-rw-r--r-- | Sluift/client.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp index 0dc7014..75f675d 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -358,6 +358,9 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( } message->addPayloads(payloads.begin(), payloads.end()); message->setType(type); + if (!getClient(L)->getClient()->isAvailable()) { + throw Lua::Exception("Trying to send message while client is offline."); + } getClient(L)->getClient()->sendMessage(message); return 0; } @@ -403,7 +406,9 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( std::vector< std::shared_ptr<Payload> > payloads = getPayloadsFromTable(L, index); presence->addPayloads(payloads.begin(), payloads.end()); } - + if (!getClient(L)->getClient()->getPresenceSender()->isAvailable()) { + throw Lua::Exception("Trying to send presence while client is offline."); + } getClient(L)->getClient()->getPresenceSender()->sendPresence(presence); lua_pushvalue(L, 1); return 0; @@ -489,7 +494,9 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( "" ) { Sluift::globals.eventLoop.runOnce(); - + if (!getClient(L)->getClient()->isAvailable()) { + throw Lua::Exception("Trying to send data while client is offline."); + } getClient(L)->getClient()->sendData(std::string(Lua::checkString(L, 2))); lua_pushvalue(L, 1); return 0; |