summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/EventController.cpp')
-rw-r--r--Swift/Controllers/EventController.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/Swift/Controllers/EventController.cpp b/Swift/Controllers/EventController.cpp
index 5141cc1..3849aa7 100644
--- a/Swift/Controllers/EventController.cpp
+++ b/Swift/Controllers/EventController.cpp
@@ -3,18 +3,23 @@
#include <boost/bind.hpp>
#include <algorithm>
+
namespace Swift {
-void EventController::handleIncomingEvent(boost::shared_ptr<MessageEvent> event) {
- if (event->isReadable()) {
- events_.push_back(event);
- event->onRead.connect(boost::bind(&EventController::handleEventRead, this, event));
+EventController::EventController() {
+}
+
+void EventController::handleIncomingEvent(boost::shared_ptr<Event> sourceEvent) {
+ boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent);
+ if (messageEvent && messageEvent->isReadable()) {
+ events_.push_back(sourceEvent);
+ messageEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, messageEvent));
onEventQueueLengthChange(events_.size());
- onEventQueueEventAdded(event);
+ onEventQueueEventAdded(sourceEvent);
}
}
-void EventController::handleEventRead(boost::shared_ptr<MessageEvent> event) {
+void EventController::handleEventConcluded(boost::shared_ptr<Event> event) {
events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end());
onEventQueueLengthChange(events_.size());
}