예제 #1
0
Bool Connection::Send( EventPtr e )
{
	PacketStream ps;

	e->Pack( ps );

	// Go through the ModifierStack, if required.
	if (GetState() == MODIFIED_LINE) 
	{
		ModifierStack* modifier_stack = GetModifierStack();

		if (modifier_stack != NULL && !ModifierSkipper::Instance().Has( e->GetEvent() ) ) 
		{
			// Exclude packet length header
			void* buffer = ps.getPtr();
			UInt32 encLength = ps.size();

			if (modifier_stack->Modify(buffer, &encLength) == false) 
			{
				// Error!!!
				return false;
			}
		}
	}

	// 공유 되므로 락 필요
	{
		asio::detail::mutex::scoped_lock sl( m_sendLock );

		m_accBuf->write( ps.size() );
		m_accBuf->write( ps.getPtr(), ps.size() );	
	}

	return requestSend(); 
}
예제 #2
0
// Internal state handling ----------------------------------------------------
uint8_t EndDevice::tick() {
	// Avoid reading packet in states that does not
	// check what the packet contains.
	switch(State) {
		case EndDeviceStart:
		case EndDeviceResetStart:
		case EndDeviceJoiningSend:
		case EndDeviceIdle:
		case EndDeviceSleeping:
		case EndDeviceWaking:
		case EndDeviceRequestSend:
		//case Error: //?
			break;
		default:
			xbee.readPacket();
	}
	switch(State) {
		case EndDeviceStart:
			return start();
		case EndDeviceFormingNetwork:
			return formingNetwork();
		case EndDeviceJoiningSend:
			return joiningSend();
		case EndDeviceJoiningWait:
			return joiningWait();
		case EndDeviceJoiningWaitResponse:
			return joiningWaitResponse();
		case EndDeviceIdle:
			return idle();
		case EndDeviceSleepWait:
			return sleepWait();
		case EndDeviceSleeping:
			return sleeping();
		case EndDeviceError:
			return error();
		case EndDeviceRequestSend:
			return requestSend();
		case EndDeviceRequestStatus:
			return requestStatus();
		case EndDeviceRequestWait:
			return requestWait();
		case EndDeviceResetStart:
			return resetStart();
		case EndDeviceResetWait:
			return resetWait();
		case EndDeviceWaking:
			return waking();
		default:
			{ DEBUG_MSG("Bad state!"); }
			return TICK_UNKNOWN_ERROR;
	}
}
예제 #3
0
void Connection::onSendCompleted(const asio::error_code& e)
{
	if ( e )
	{
		m_socket.close();

		onError(e);

		return;
	}

	// 락 범위
	{
		asio::detail::mutex::scoped_lock sl( m_sendLock ); 

		m_sending = false;
	}

	requestSend();
}
예제 #4
0
 void ZMQtClient_P::send( const QByteArray &data )
 {
     emit requestSend(data);
 }