summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/EventLoop/SimpleEventLoop.cpp11
-rw-r--r--Swiften/EventLoop/SimpleEventLoop.h2
-rw-r--r--Swiften/QA/ScriptedTests/SendMessage.lua4
3 files changed, 15 insertions, 2 deletions
diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp
index 2d71544..b77639c 100644
--- a/Swiften/EventLoop/SimpleEventLoop.cpp
+++ b/Swiften/EventLoop/SimpleEventLoop.cpp
@@ -44,6 +44,17 @@ void SimpleEventLoop::doRun(bool breakAfterEvents) {
}
}
+void SimpleEventLoop::runOnce() {
+ std::vector<Event> events;
+ {
+ boost::unique_lock<boost::mutex> lock(eventsMutex_);
+ events.swap(events_);
+ }
+ foreach(const Event& event, events) {
+ handleEvent(event);
+ }
+}
+
void SimpleEventLoop::stop() {
postEvent(boost::bind(&SimpleEventLoop::doStop, this));
}
diff --git a/Swiften/EventLoop/SimpleEventLoop.h b/Swiften/EventLoop/SimpleEventLoop.h
index bdffa3d..6fb3f53 100644
--- a/Swiften/EventLoop/SimpleEventLoop.h
+++ b/Swiften/EventLoop/SimpleEventLoop.h
@@ -27,6 +27,8 @@ namespace Swift {
doRun(true);
}
+ void runOnce();
+
void stop();
virtual void post(const Event& event);
diff --git a/Swiften/QA/ScriptedTests/SendMessage.lua b/Swiften/QA/ScriptedTests/SendMessage.lua
index a3f1917..8c54d00 100644
--- a/Swiften/QA/ScriptedTests/SendMessage.lua
+++ b/Swiften/QA/ScriptedTests/SendMessage.lua
@@ -33,12 +33,12 @@ received_message = client2:for_event(function(event)
if event["type"] == "message" and event["from"] == client1_jid then
return event["body"]
end
- end)
+ end, 10000)
assert(received_message == "Hello")
print "Retrieving the roster"
roster = client1:get_roster()
-table.foreach(roster, print)
+tprint(roster)
client1:disconnect()
client2:disconnect()