TEST(ReplicateStateMessage, ReplicatesNetworkComponentDirtyStatesWhenDirtyReplicationIsTrue)
		{
			REGISTER_MESSAGE(ReplicateInstanceMessage);
			REGISTER_MESSAGE(ReplicateStateMessage);
			REGISTER_CONSTRUCTOR(MockNetworkGameObjectWithState);

			MockNetworkGameObjectWithState gameObject;
			gameObject.setInstanceId(1);

			gameObject.variable1 = 1;
			gameObject.variable2 = 2;

			serverManager->sendMessage(ReplicateInstanceMessage(&gameObject, Role_None), clientAddress1);
			clientManager1->update();

			//First replicate all variables
			serverManager->sendMessage(ReplicateStateMessage(&gameObject), clientAddress1);
			clientManager1->update();

			gameObject.variable1 = 3;
			gameObject.variable2 = 4;

			gameObject.variable1.setDirty(false);
			gameObject.variable2.setDirty(true);

			serverManager->sendMessage(ReplicateStateMessage(&gameObject, true), clientAddress1);
			clientManager1->update();

			auto replicatedObject = dynamic_cast<MockNetworkGameObjectWithState *> (clientManager1->findNetworkGameObject(gameObject.getInstanceId()));

			CHECK_EQUAL(1, replicatedObject->variable1.getValue());
			CHECK_EQUAL(4, replicatedObject->variable2.getValue());
		}
void mog::network::ServerNetworkManager::processStateReplications()
{
	for (auto netObjetPair : networkGameObjects)
	{
		if (netObjetPair.second->isDirty())
		{
			for (auto clientRep : clientReplicationInfos)
				sendMessage(ReplicateStateMessage(netObjetPair.second, true), *(clientRep->getAddress()));
			netObjetPair.second->setDirty(false);
		}

	}

}
void mog::network::ServerNetworkManager::processInstanceReplications()
{
	for (auto clientRep : clientReplicationInfos)
	{
		while (!clientRep->isToBeReplicatedEmpty())
		{
			auto instanceId = clientRep->getToBeReplicatedInstance();
			auto obj = findNetworkGameObject(instanceId);
			Role role = Role_None;
			if (*clientRep->getClient() == *obj->getClient())
				role = Role_Proxy;
			else
				role = Role_Simulated;

			sendMessage(ReplicateInstanceMessage(obj, role), *(clientRep->getAddress()));
			sendMessage(ReplicateStateMessage(obj), *(clientRep->getAddress()));
			clientRep->eraseToBeReplicatedInstance(instanceId);
		}
	}
}