From d20c00c77a07562b5e385ef0b1d957007913348b Mon Sep 17 00:00:00 2001 From: Roger Planas Date: Tue, 9 Dec 2014 17:05:33 +0000 Subject: Sluift: Add a get_options to retrieve connection settings Change-Id: I3767f479609bf64cc6d64932e125c2e66e5f75eb diff --git a/Sluift/client.cpp b/Sluift/client.cpp index e8e6a1a..b6c39dd 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -457,6 +457,28 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( return 0; } +SLUIFT_LUA_FUNCTION_WITH_HELP( + Client, get_options, + "Returns a table with all the connection options of this client.", + "self\n", + "" +) { + Sluift::globals.eventLoop.runOnce(); + + SluiftClient* client = getClient(L); + Lua::Table optionsTable = boost::assign::map_list_of + ("host", boost::make_shared(client->getOptions().manualHostname)) + ("port", boost::make_shared(client->getOptions().manualPort)) + ("ack", boost::make_shared(client->getOptions().useAcks)) + ("compress", boost::make_shared(client->getOptions().useStreamCompression)) + ("tls", boost::make_shared(client->getOptions().useTLS == ClientOptions::NeverUseTLS ? false : true)) + ("bosh_url", boost::make_shared(client->getOptions().boshURL.toString())) + ("allow_plain_without_tls", boost::make_shared(client->getOptions().allowPLAINWithoutTLS)); + pushValue(L, optionsTable); + Lua::registerTableToString(L, -1); + return 1; +} + static void pushEvent(lua_State* L, const SluiftClient::Event& event) { switch (event.type) { case SluiftClient::Event::MessageType: { -- cgit v0.10.2-6-g49f6