diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-05-04 14:00:53 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-05-04 14:02:45 (GMT) |
commit | 0b3db8fd68abee7269d5a38aabd8a816e099eae5 (patch) | |
tree | b61ce960c549ff82cd25265449f5a21c9a1b14e9 | |
parent | 7d2074bc046c38cf6947da77e1b9610c1809217d (diff) | |
download | swift-contrib-0b3db8fd68abee7269d5a38aabd8a816e099eae5.zip swift-contrib-0b3db8fd68abee7269d5a38aabd8a816e099eae5.tar.bz2 |
Add Sluift ability to specify host to connect to.
-rw-r--r-- | Sluift/sluift.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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; } |