Ejemplo n.º 1
0
static void client()
{
	log4cxx::NDC ndc("client");
	ORWELL_LOG_INFO("client ...");
	zmq::context_t aContext(1);
	usleep(1 * 1000);
	ORWELL_LOG_INFO("create pusher");
	Sender aPusher("tcp://127.0.0.1:9000", ZMQ_PUSH, orwell::com::ConnectionMode::CONNECT, aContext);
	ORWELL_LOG_INFO("create subscriber");
	Receiver aSubscriber("tcp://127.0.0.1:9001", ZMQ_SUB, orwell::com::ConnectionMode::CONNECT, aContext);
	usleep(1 * 1000);

	ExpectGameState(false, aSubscriber);

	Hello aHelloMessage;
	aHelloMessage.set_name("playername");
	RawMessage aMessage("randomid", "Hello", aHelloMessage.SerializeAsString());
	aPusher.send(aMessage);

	ExpectGameState(true, aSubscriber);

	aPusher.send(aMessage);

	ORWELL_LOG_INFO("quit client");
}