예제 #1
0
void Socket::sendString(std::string const & iMessage)
{
	zmq::message_t aZmqMessage(iMessage.size());
	memcpy((void *) aZmqMessage.data(), iMessage.c_str(), iMessage.size());

	try
	{
		m_zmqSocket->send(aZmqMessage);
		ORWELL_LOG_TRACE("Sent " << iMessage);
	}
	catch (...)
	{
		ORWELL_LOG_TRACE("Failed to send zmq message.");
	}
}
예제 #2
0
void Socket::sendString(std::string const & iMessage)
{
	zmq::message_t aZmqMessage(iMessage.size());
	memcpy((void *) aZmqMessage.data(), iMessage.c_str(), iMessage.size());

	m_zmqSocket->send(aZmqMessage);
	ORWELL_LOG_TRACE("Sent " << iMessage );
}
예제 #3
0
void Socket::send( RawMessage const & iMessage )
{
	string aMessage;
	aMessage += iMessage._routingId;
	aMessage += " ";
	aMessage += iMessage._type;
	aMessage += " ";
	aMessage += iMessage._payload;

	sendString(aMessage);
	ORWELL_LOG_TRACE("Sent " << aMessage.size() << " bytes : " << iMessage._type << "-");
}
예제 #4
0
void ProcessTimer::execute()
{
    ORWELL_LOG_TRACE("ProcessTimer::execute : broadcast Gamestate");

    GameState aGameState;
    aGameState.set_playing(m_game->getIsRunning());

    if (m_game->getWinner())
    {
        aGameState.set_winner(*m_game->getWinner());
    }

    RawMessage aMessage("all_clients", "GameState", aGameState.SerializeAsString());
    m_publisher->send( aMessage );
}
예제 #5
0
bool Socket::receiveString(
		std::string & oMessage,
		bool const iBlocking)
{
	zmq::message_t aZmqMessage;

	int aFlags = 0;
	if (not iBlocking)
	{
		aFlags = ZMQ_NOBLOCK;
	}
	bool const aReceived = m_zmqSocket->recv(&aZmqMessage, aFlags);
	if (aReceived)
	{
		ORWELL_LOG_TRACE("message received");
		oMessage = string(static_cast<char*>(aZmqMessage.data()), aZmqMessage.size());
	}
	return aReceived;
}