Пример #1
0
void
RemoteCommunicatorI::addUpdateCallback(const Ice::Current&)
{
    IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);

    Ice::ObjectPtr propFacet = _communicator->findAdminFacet("Properties");
    if(propFacet)
    {
        Ice::NativePropertiesAdminPtr admin = ICE_DYNAMIC_CAST(Ice::NativePropertiesAdmin, propFacet);
        assert(admin);
#ifdef ICE_CPP11_MAPPING
        _removeCallback =
            admin->addUpdateCallback([this](const Ice::PropertyDict& changes) { updated(changes); });
#else
        admin->addUpdateCallback(this);
        _hasCallback = true;
#endif
    }
}
Пример #2
0
void
RemoteCommunicatorI::removeUpdateCallback(const Ice::Current&)
{
    IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);

    Ice::ObjectPtr propFacet = _communicator->findAdminFacet("Properties");
    if(propFacet)
    {
        Ice::NativePropertiesAdminPtr admin = ICE_DYNAMIC_CAST(Ice::NativePropertiesAdmin, propFacet);
        assert(admin);
#ifdef ICE_CPP11_MAPPING
        if(_removeCallback)
        {
            _removeCallback();
            _removeCallback = nullptr;
        }
#else
        admin->removeUpdateCallback(this);
        _hasCallback = false;
#endif
    }

}
Пример #3
0
int
Server::run(int argc, char*[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    PropsIPtr props = new PropsI;

    //
    // Retrieve the PropertiesAdmin facet and register the servant as the update callback.
    //
    Ice::ObjectPtr obj = communicator()->findAdminFacet("Properties");
    Ice::NativePropertiesAdminPtr admin = Ice::NativePropertiesAdminPtr::dynamicCast(obj);
    admin->addUpdateCallback(props);

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Props");
    adapter->add(props, communicator()->stringToIdentity("props"));
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}