Пример #1
0
bool EnhancedVtoRouter::CheckIncomingVtoData(const VtoData& arData)
{
	switch(arData.GetType()) {
	case(VTODT_DATA):
		if(mInstRemoteConnected) return true;
		else {
			LOG_BLOCK(LEV_WARNING, "Discarding received data, because remote side is offline");
			this->HandleReceivingDataWhenRemoteClosed();
			return false;
		}
	case(VTODT_REMOTE_OPENED):
		if(mInstRemoteConnected) {
			LOG_BLOCK(LEV_WARNING, "Remote side opened, but it was already open");
			this->HandleDuplicateOpen();
			return false;
		}
		else {
			mInstRemoteConnected = true;
			return true;
		}
	case(VTODT_REMOTE_CLOSED):
		if(mInstRemoteConnected) {
			mInstRemoteConnected = false;
			return true;
		}
		else {
			LOG_BLOCK(LEV_WARNING, "Remote side closed, but it was already closed");
			this->HandleDuplicateClose();
			return false;
		}
	default:
		throw ArgumentException(LOCATION, "Unknown VtoData type");
	}
}
Пример #2
0
void VtoRouter::OnVtoDataReceived(const VtoData& arData)
{
	LOG_BLOCK(LEV_DEBUG, "GotRemoteData: " << arData.GetSize() << " Type: " << ToString(arData.GetType()));

	if(this->CheckIncomingVtoData(arData)) {
		/*
		 * Each physical layer action is processed serially, so we can take
		 * advantage of the FIFO structure to keep things simple.
		 */
		this->mPhysLayerTxBuffer.push(arData);
		this->CheckForPhysWrite();
	}
}
Пример #3
0
void VtoRouter::OnVtoDataReceived(const VtoData& arData)
{
	// this callback may be coming from another strand (i.e. a stack) and therefore must be synchronized
	mpPhys->GetExecutor()->Post([this, arData]() {

		LOG_BLOCK(LEV_DEBUG, "GotRemoteData: " << arData.GetSize() << " Type: " << ToString(arData.GetType()));

		if(this->CheckIncomingVtoData(arData)) {
			/*
			 * Each physical layer action is processed serially, so we can take
			 * advantage of the FIFO structure to keep things simple.
			 */
			this->mPhysLayerTxBuffer.push(arData);
			this->CheckForPhysWrite();
		}

	});
}