bool InboundNamedPipeCarrier::OnEvent(select_event &event) {
	if (_pProtocol == NULL) {
		ASSERT("This pipe has no upper protocols");
		return false;
	}

	int32_t recvAmount = 0;

	switch (event.type) {
		case SET_READ:
		{
			IOBuffer *pInputBuffer = _pProtocol->GetInputBuffer();
			o_assert(pInputBuffer != NULL);
			if (!pInputBuffer->ReadFromPipe(_inboundFd,
					FD_READ_CHUNK, recvAmount)) {
				FATAL("Unable to read data");
				return false;
			}

			return _pProtocol->SignalInputData(recvAmount);
		}
		default:
		{
			ASSERT("Invalid state: %hhu", event.type);
			return false;
		}
	}
}
bool InboundNamedPipeCarrier::OnEvent(struct epoll_event &event) {
	if (_pProtocol == NULL) {
		ASSERT("This pipe has no upper protocols");
		return false;
	}

	int32_t recvBytes = 0;

	if ((event.events & EPOLLIN) != 0) {
		IOBuffer *pInputBuffer = _pProtocol->GetInputBuffer();
		o_assert(pInputBuffer != NULL);
		if (!pInputBuffer->ReadFromPipe(_inboundFd, FD_READ_CHUNK,
				recvBytes)) {
			FATAL("Unable to read data");
			return false;
		}

		return _pProtocol->SignalInputData(recvBytes);
	} else if (event.events & EPOLLHUP) {
		WARN("This is a HUP");
		if (_pProtocol != NULL)
			_pProtocol->EnqueueForDelete();
		return false;
	} else {
		ASSERT("Invalid state: %x", event.events);

		return false;
	}
}
bool InboundNamedPipeCarrier::OnEvent(struct kevent &event) {
	if (_pProtocol == NULL) {
		ASSERT("This pipe has no upper protocols");
		return false;
	}

	int32_t recvAmount = 0;

	switch (event.filter) {
		case EVFILT_READ:
		{
			IOBuffer *pInputBuffer = _pProtocol->GetInputBuffer();
			assert(pInputBuffer != NULL);
			if (!pInputBuffer->ReadFromPipe(event.ident, event.data, recvAmount)) {
				FATAL("Unable to read data");
				return false;
			}

			return _pProtocol->SignalInputData(recvAmount);
		}
		default:
		{
			ASSERT("Invalid state: %hu", event.filter);
			return false;
		}
	}
}