diff options
Diffstat (limited to 'Sluift/component.cpp')
-rw-r--r-- | Sluift/component.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Sluift/component.cpp b/Sluift/component.cpp index e92352e..a9ac2d9 100644 --- a/Sluift/component.cpp +++ b/Sluift/component.cpp @@ -335,61 +335,61 @@ SLUIFT_LUA_FUNCTION(Component, get) { } SLUIFT_LUA_FUNCTION(Component, set) { return sendQuery(L, IQ::Set); } SLUIFT_LUA_FUNCTION_WITH_HELP( Component, send, "Sends a raw string", "self\n" "data the string to send\n", "" ) { Sluift::globals.eventLoop.runOnce(); getComponent(L)->getComponent()->sendData(std::string(Lua::checkString(L, 2))); lua_pushvalue(L, 1); return 0; } static void pushEvent(lua_State* L, const SluiftComponent::Event& event) { switch (event.type) { case SluiftComponent::Event::MessageType: { Message::ref message = boost::dynamic_pointer_cast<Message>(event.stanza); Lua::Table result = boost::assign::map_list_of ("type", boost::make_shared<Lua::Value>(std::string("message"))) ("from", boost::make_shared<Lua::Value>(message->getFrom().toString())) ("to", boost::make_shared<Lua::Value>(message->getTo().toString())) - ("body", boost::make_shared<Lua::Value>(message->getBody())) + ("body", boost::make_shared<Lua::Value>(message->getBody().get_value_or(""))) ("message_type", boost::make_shared<Lua::Value>(MessageConvertor::convertMessageTypeToString(message->getType()))); Lua::pushValue(L, result); addPayloadsToTable(L, message->getPayloads()); Lua::registerTableToString(L, -1); break; } case SluiftComponent::Event::PresenceType: { Presence::ref presence = boost::dynamic_pointer_cast<Presence>(event.stanza); Lua::Table result = boost::assign::map_list_of ("type", boost::make_shared<Lua::Value>(std::string("presence"))) ("from", boost::make_shared<Lua::Value>(presence->getFrom().toString())) ("to", boost::make_shared<Lua::Value>(presence->getTo().toString())) ("status", boost::make_shared<Lua::Value>(presence->getStatus())) ("presence_type", boost::make_shared<Lua::Value>(PresenceConvertor::convertPresenceTypeToString(presence->getType()))); Lua::pushValue(L, result); addPayloadsToTable(L, presence->getPayloads()); Lua::registerTableToString(L, -1); break; } } } struct CallUnaryLuaPredicateOnEvent { CallUnaryLuaPredicateOnEvent(lua_State* L, int index) : L(L), index(index) { } bool operator()(const SluiftComponent::Event& event) { lua_pushvalue(L, index); pushEvent(L, event); if (lua_pcall(L, 1, 1, 0) != 0) { |