diff options
| author | Roger Planas <roger.planas@isode.com> | 2014-12-09 17:05:33 (GMT) | 
|---|---|---|
| committer | Swift Review <review@swift.im> | 2014-12-10 14:35:05 (GMT) | 
| commit | d20c00c77a07562b5e385ef0b1d957007913348b (patch) | |
| tree | 8c3ab285584b09513a1fa5e5034a578c107c36db | |
| parent | cfac388d57a5165e845251f17469472cfa4bb542 (diff) | |
| download | swift-d20c00c77a07562b5e385ef0b1d957007913348b.zip swift-d20c00c77a07562b5e385ef0b1d957007913348b.tar.bz2 | |
Sluift: Add a get_options to retrieve connection settings
Change-Id: I3767f479609bf64cc6d64932e125c2e66e5f75eb
| -rw-r--r-- | Sluift/client.cpp | 22 | 
1 files changed, 22 insertions, 0 deletions
| 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<Lua::Value>(client->getOptions().manualHostname)) +		("port", boost::make_shared<Lua::Value>(client->getOptions().manualPort)) +		("ack", boost::make_shared<Lua::Value>(client->getOptions().useAcks)) +		("compress", boost::make_shared<Lua::Value>(client->getOptions().useStreamCompression)) +		("tls", boost::make_shared<Lua::Value>(client->getOptions().useTLS == ClientOptions::NeverUseTLS ? false : true)) +		("bosh_url", boost::make_shared<Lua::Value>(client->getOptions().boshURL.toString())) +		("allow_plain_without_tls", boost::make_shared<Lua::Value>(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: { | 
 Swift
 Swift