summaryrefslogtreecommitdiffstats
blob: 9b143ddb529fd65b939e93ee41d809f2d3ace339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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());
}

}