From 0b3db8fd68abee7269d5a38aabd8a816e099eae5 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Wed, 4 May 2011 15:00:53 +0100
Subject: Add Sluift ability to specify host to connect to.


diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp
index b911772..4f762fa 100644
--- a/Sluift/sluift.cpp
+++ b/Sluift/sluift.cpp
@@ -71,6 +71,11 @@ class SluiftClient {
 			client->connect();
 		}
 
+		void connect(const std::string& host) {
+			rosterReceived = false;
+			client->connect(host);
+		}
+
 		void waitConnected() {
 			Watchdog watchdog(globalTimeout, networkFactories.getTimerFactory());
 			while (!watchdog.getTimedOut() && client->isActive() && !client->isAvailable()) {
@@ -200,7 +205,13 @@ static inline SluiftClient* getClient(lua_State* L) {
 static int sluift_client_connect(lua_State *L) {
 	try {
 		SluiftClient* client = getClient(L);
-		client->connect();
+		std::string host(luaL_checkstring(L, 2));
+		if (host.empty()) {
+			client->connect();
+		}
+		else {
+			client->connect(host);
+		}
 		client->waitConnected();
 		return 1;
 	}
-- 
cgit v0.10.2-6-g49f6