summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-05-04 14:00:53 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-05-04 14:02:45 (GMT)
commit0b3db8fd68abee7269d5a38aabd8a816e099eae5 (patch)
treeb61ce960c549ff82cd25265449f5a21c9a1b14e9 /Sluift
parent7d2074bc046c38cf6947da77e1b9610c1809217d (diff)
downloadswift-contrib-0b3db8fd68abee7269d5a38aabd8a816e099eae5.zip
swift-contrib-0b3db8fd68abee7269d5a38aabd8a816e099eae5.tar.bz2
Add Sluift ability to specify host to connect to.
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/sluift.cpp13
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;
}