From 503a8077c8811c2e9f65a619c33690a36eb5c153 Mon Sep 17 00:00:00 2001
From: Roger Planas <roger.planas@isode.com>
Date: Fri, 13 Dec 2013 11:32:13 +0000
Subject: Sluift: Fix default values for port and host for connect

Change-Id: Ia19e0a3763005df7fb7db6b57841d6559f74ef46

diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp
index 184fbd6..257eec1 100644
--- a/Sluift/SluiftClient.cpp
+++ b/Sluift/SluiftClient.cpp
@@ -56,6 +56,7 @@ void SluiftClient::connect(const std::string& host, int port) {
 	rosterReceived = false;
 	options.manualHostname = host;
 	options.manualPort = port;
+	disconnectedError = boost::optional<ClientError>();
 	if (globals->debug) {
 		tracer = new ClientXMLTracer(client, options.boshURL.isEmpty()? false: true);
 	}
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index 2ca62d6..cd675fa 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -47,8 +47,8 @@ static inline SluiftClient* getClient(lua_State* L) {
 SLUIFT_LUA_FUNCTION(Client, async_connect) {
 	SluiftClient* client = getClient(L);
 
-	std::string host;
-	int port = -1;
+	std::string host = client->getOptions().manualHostname;
+	int port = client->getOptions().manualPort;
 	if (lua_istable(L, 2)) {
 		if (boost::optional<std::string> hostString = Lua::getStringField(L, 2, "host")) {
 			host = *hostString;
@@ -57,12 +57,7 @@ SLUIFT_LUA_FUNCTION(Client, async_connect) {
 			port = *portInt;
 		}
 	}
-	if (host.empty() && port == -1) {
-		client->connect();
-	}
-	else {
-		client->connect(host, port);
-	}
+	client->connect(host, port);
 	return 0;
 }
 
-- 
cgit v0.10.2-6-g49f6