summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift/SluiftClient.cpp')
-rw-r--r--Sluift/SluiftClient.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp
index 9db8969..d2b1beb 100644
--- a/Sluift/SluiftClient.cpp
+++ b/Sluift/SluiftClient.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -125,13 +125,21 @@ boost::optional<SluiftClient::Event> SluiftClient::getNextEvent(
}
}
-std::vector<XMPPRosterItem> SluiftClient::getRoster() {
+std::vector<XMPPRosterItem> SluiftClient::getRoster(int timeout) {
+ Watchdog watchdog(timeout, networkFactories->getTimerFactory());
if (!rosterReceived) {
// If we haven't requested it yet, request it for the first time
client->requestRoster();
- }
- while (!rosterReceived) {
- eventLoop->runUntilEvents();
+
+ // Wait for new events
+ while (!watchdog.getTimedOut() && !rosterReceived) {
+ eventLoop->runUntilEvents();
+ }
+
+ // Throw an error if we're timed out
+ if (watchdog.getTimedOut()) {
+ throw Lua::Exception("Timeout while requesting roster");
+ }
}
return client->getRoster()->getItems();
}