diff options
Diffstat (limited to 'Swift/Controllers/EventController.cpp')
-rw-r--r-- | Swift/Controllers/EventController.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Swift/Controllers/EventController.cpp b/Swift/Controllers/EventController.cpp new file mode 100644 index 0000000..9b143dd --- /dev/null +++ b/Swift/Controllers/EventController.cpp @@ -0,0 +1,21 @@ +#include "Swift/Controllers/EventController.h" + +#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)); + onEventQueueLengthChange(events_.size()); + } +} + +void EventController::handleEventRead(boost::shared_ptr<MessageEvent> event) { + events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); + onEventQueueLengthChange(events_.size()); +} + +} |