DetectorPrx initIceConnection(const std::string& detectorNameStr,
                              Ice::Identity& det_cb,
                              DetectorCallbackHandlerPtr cr)
{
  
  initIce(detectorNameStr);
  
  Ice::PropertiesPtr props = iceComm->getProperties();
  std::string proxStr = detectorNameStr + ".Proxy";
  DetectorPrx detector = NULL;
  try
  {
  
    detector = DetectorPrx::checkedCast(
        iceComm->propertyToProxy(proxStr)->ice_twoway());
  }
  catch (const IceUtil::NullHandleException& e)
  {
    localAndClientMsg( VLogger::ERROR, NULL, "Invalid proxy: '%s'. %s\n", 
                       detectorNameStr.c_str(), e.what());
    return NULL;
  }

  Ice::ObjectAdapterPtr adapter = iceComm->createObjectAdapter("");
  det_cb.name = IceUtil::generateUUID();
  det_cb.category = "";
  adapter->add(cr, det_cb);
  adapter->activate();
  detector->ice_getConnection()->setAdapter(adapter);    
  
  // note that we need an ObjectAdapter to permit bidirectional communication
  // if we want to get past firewalls without Glacier2
  
  return detector;  // Success
}
Beispiel #2
0
 /// usage:
    ///IceBoxTestClientApp.exe <detector> <directory>
    /// <detector>: The name of the detector (found in the config.client file)
    /// <directory>: The full path to a folder containing images to process
    /// Returns 0 on success ('EXIT_SUCCESS'), and 1 on failure ('EXIT_FAILURE')
DetectorPrx ClientApp::initIceConnection(std::string detectorNameStr)
{  // Connect to the Ice Service
	Ice::PropertiesPtr props = communicator()->getProperties();
    std::string proxStr = detectorNameStr + ".Proxy";
    DetectorPrx detector = NULL;
    try
    {
        detector = DetectorPrx::checkedCast(
                               communicator()->propertyToProxy(proxStr)->ice_twoway());
    }
    catch (const IceUtil::NullHandleException& e)
    {
       localAndClientMsg(VLogger::WARN, NULL, "Invalid proxy: '%s'. %s\n", 
               detectorNameStr.c_str(), e.what());
       return NULL;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("");
    ident.name = IceUtil::generateUUID();
    ident.category = "";
    DetectorCallbackHandlerPtr cr = new CallbackHandlerI(appData);
    adapter->add(cr, ident);
    adapter->activate();
    detector->ice_getConnection()->setAdapter(adapter);    

    // note that we need an ObjectAdapter to permit bidirectional communication
    // if we want to get past firewalls without Glacier2

    localAndClientMsg(VLogger::DEBUG, NULL, "IceBox test client: created callbackHandler proxy\n");
                
    if(!detector)
    {
		localAndClientMsg(VLogger::WARN, NULL, "%s: invalid proxy \n", appName());
		return NULL;
    }
    else
		return detector;  // Success

#if 0
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("");
    Ice::Identity ident;
    ident.name = IceUtil::generateUUID();
    ident.category = "";
    CallbackReceiverPtr cr = new CallbackReceiverI;
    adapter->add(cr, ident);
    adapter->activate();
    detector->ice_getConnection()->setAdapter(adapter);
    printf("about to call addClient\n");
//    RunSet runSet;
//    detector->process(ident, runSet);
    detector->addClient(ident);
    printf("just called addClient\n");
    communicator()->waitForShutdown();

    return 0;
#elif 0
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("");
    Ice::Identity ident;
    ident.name = IceUtil::generateUUID();
    ident.category = "";
    DetectorCallbackHandlerPtr cr = new CallbackHandlerI;
    adapter->add(cr, ident);
    adapter->activate();
    detector->ice_getConnection()->setAdapter(adapter);
    printf("about to call process\n");
    RunSet runSet;
    detector->process(ident, runSet);
//    detector->addClient(ident);
    printf("just called process\n");
    communicator()->waitForShutdown();

    return 0;
#endif

}