当前位置: 首页>>代码示例>>C++>>正文


C++ SimpleClient类代码示例

本文整理汇总了C++中SimpleClient的典型用法代码示例。如果您正苦于以下问题:C++ SimpleClient类的具体用法?C++ SimpleClient怎么用?C++ SimpleClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimpleClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: simpleclient_connect_lua

static int simpleclient_connect_lua(lua_State* L) {
	SimpleClient* mc = (SimpleClient*)lua_topointer(L, -3);
	const char* ip = lua_tostring(L, -2);
	const char* port = lua_tostring(L, -1);
	mc->connect(ip, port);
	return 0;
}
开发者ID:wonghoifung,项目名称:tips,代码行数:7,代码来源:main.cpp

示例2: main

int main(int argc, char *argv[])
{
    // Creates and initializes the SimpleClient object
    SimpleClient client;
    if (client.init(argc,argv) == 0)
	{

	return -1;
	}
    else
	{
	//Must log into manager before we can really do anything
	client.login();
	}

    int nlogs = atoi(argv[1]);
    int i;
    for ( i=0;i<nlogs;i++)
        ACS_SHORT_LOG((LM_INFO,"Sending log number %d", i));
    
    client.logout();
    
    ACE_OS::sleep(3);
    return 0;
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:25,代码来源:LogSenderClient.cpp

示例3: main

int main(int argc, char *argv[]) 
{
    ACS_SHORT_LOG((LM_INFO, "Welcome to %s!", argv[0]));

    long numLogins = std::atol(argv[1]);
    long sleepTime = std::atol(argv[2]);

    //Creates and initializes the SimpleClient object
    SimpleClient client;
    if (client.init(argc,argv) == 0)
	{
	ACE_DEBUG((LM_DEBUG,"Cannot init client"));
	return -1;
	}

    for (long i=0; i< numLogins; i++)
	{
	client.login();

	ACE_OS::sleep(sleepTime);
	client.logout();
	}

    ACS_SHORT_LOG ((LM_INFO, "The end!"));
    return 0;
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:26,代码来源:stressManager.cpp

示例4: main

int main (int argc, char **argv)
{
  ACS_SHORT_LOG ((LM_INFO, "Init maciLogConfigTestClient..."));
  SimpleClient client;
  MACI_TEST::LogConfigTestClass_ptr comp;
    if (client.init(argc,argv) == 0)
	{
	return -1;
	}
    else
	{
	//Must log into manager before we can really do anything
	client.login();
	}
  try
    {
	comp = client.getComponent<MACI_TEST::LogConfigTestClass>("MACI_LOG_CONFIG",0,true);

	comp->log_all();


        client.releaseComponent ("MACI_LOG_CONFIG");
    	client.logout();

    }
  catch ( CORBA::Exception &ex )
    {
      ACE_PRINT_EXCEPTION(ex, "main");
    }

  ACS_SHORT_LOG ((LM_INFO, "Exiting maciLogConfigTestClient..."));
  return 0;

} /* end main() */
开发者ID:guigue,项目名称:ACS,代码行数:34,代码来源:maciTestLogConfigClient.cpp

示例5: main

int main(int argc, char *argv[]) {

	SimpleClient client;
	if( client.init(argc, argv) == 0 ) {
		cerr << "Cannot initialize client, not continuing" << endl;
		return 1;
	}
	client.login();

	try {

		ACS_SHORT_LOG((LM_INFO,"Obtaining reference to NEWCONFIG_RECEIVER"));
		bulkdata::BulkDataReceiver_var receiver = client.getComponent<bulkdata::BulkDataReceiver>("NEWCONFIG_RECEIVER", 0, true);
	
		// This stream is not configuredon the CDB, will use a default configuration
		ACS_SHORT_LOG((LM_INFO,"Opening stream 'no_existing_stream' (not in CDB)"));
		receiver->openReceiverStream("no_existing_stream");
	
		// This is configured on the CDB, cool
		ACS_SHORT_LOG((LM_INFO,"Opening stream 'Name1' (in CDB)"));
		receiver->openReceiverStream("Name1");
		sleep(2);

		// Open the rest of the receivers
		ACS_SHORT_LOG((LM_INFO,"Opening all remaining streams (namely, Name7)"));
		receiver->openReceiver();
	
		// now sleep a little bit
		ACS_SHORT_LOG((LM_INFO,"Sleeping 10 seconds"));
		ACE_OS::sleep(10);
	
		// and close the receivers
	
		// woops, this doesn't exist
		ACS_SHORT_LOG((LM_INFO,"Closing stream 'name12'"));
		receiver->closeReceiverStream("name12");
	
		// This was the one we wanted to close before
		ACS_SHORT_LOG((LM_INFO,"Closing stream 'Name1'"));
		receiver->closeReceiverStream("Name1");
		ACS_SHORT_LOG((LM_INFO,"Closing stream 'no_existing_stream' (but now it does exist)"));
		receiver->closeReceiverStream("no_existing_stream");
	
		// close the rest
		ACS_SHORT_LOG((LM_INFO,"Closing remaining streams"));
		receiver->closeReceiver();

		// Close receiver
		client.releaseComponent("NEWCONFIG_RECEIVER");

	} catch(maciErrType::CannotGetComponentExImpl &ex) {
		cerr << "Cannot get component '" << ex.getCURL() << "'. Reason: " << ex.getReason() << endl;
	} catch(...) {
		cerr << "Unexpected exception while running test code" << endl;
		client.logout();
	}
}
开发者ID:LeoXDXp,项目名称:ACS,代码行数:57,代码来源:bdNTReceiverImplClient.cpp

示例6: item

/*!
 * Создание итема на основе текущего активного подключения.
 *
 * \param id Base32 кодированный идентификатор сервера с именем провайдера.
 */
NetworkItem* NetworkItem::item(const QByteArray &id)
{
  SimpleClient *client = ChatClient::io();
  NetworkItem *item = new NetworkItem(id);

  item->m_name   = ChatClient::serverName();
  item->m_url    = client->url().toString();
  item->m_cookie = client->cookie().toByteArray();
  item->m_userId = client->channelId();

  return item;
}
开发者ID:johnbolia,项目名称:schat,代码行数:17,代码来源:NetworkManager.cpp

示例7: main

/** @cond
*/    
int main(int argc, char *argv[])
{
    SimpleClient client;
    int ret;

// Creates and initializes the SimpleClient object

    std::cout << "Initializing client..." << std::endl;
    std::cout.flush();
    if (client.init(argc,argv) == 0) return -1;

    //Must log into manager before we can really do anything
    client.login();

    try
	{
	ComponentSmartPtr<acsexmplHelloWorld::HelloWorld> foo;
	//Get the specific component we have requested on the command-line
	foo = client.getComponentSmartPtr<acsexmplHelloWorld::HelloWorld>(argv[1], 0, true);

	//Call the displayMessage() method existing in the interface for HelloWorld
	foo->displayMessage();
    
	try
	    {
	    foo->badMethod();
	    }
	catch(ACSErrTypeCommon::UnknownEx &ex)
	    {
	    ACSErrTypeCommon::UnknownExImpl badMethodEx(ex);
	    badMethodEx.log();
	    ACS::Time timeStamp = badMethodEx.getTimeStamp();
	    ACE_CString tString = getStringifiedUTC(timeStamp);
	    ACS_DEBUG_PARAM(argv[0], "Time of the exception: %s\n", tString.c_str());
	    }

	ret = 0;
	}
    catch(maciErrType::CannotGetComponentExImpl &_ex)
	{
	_ex.log();
	ret = -1;
	}

    client.logout();
    
    //Sleep for 3 sec to allow everytihng to cleanup and stablize
    ACE_OS::sleep(3);

    return 0;
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:53,代码来源:acsexmplClientHelloWorldSP.cpp

示例8: main

int main(int argc, char**)
{
    using example::SimpleClient;
    
    SimpleClient client;
    client.connect("127.0.0.1");
    client.createSchema();
    client.loadData();
    client.querySchema();
    client.updateSchema();
    client.dropSchema("simplex");
    client.close();
    return 0;
}
开发者ID:aluo86,项目名称:cassandra-samples,代码行数:14,代码来源:simple.cpp

示例9: main

int main(int argc, char *argv[])
{
    SimpleClient client;
    if (client.init(argc,argv) == 0)
	{
	return -1;
	}
    else
	{
	client.login();
	}

    CORBA::ULong invocations = static_cast<CORBA::ULong>(std::atol(argv[1]));
 
    for (unsigned int i=0; i < invocations; i++)
	{
	ACS_SHORT_LOG((LM_INFO, "A message"));
	}

    
    client.logout();
    return 0;
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:23,代码来源:stressLogging.cpp

示例10: accepted

void Benchmark::clientStateChanged(int state, int previousState)
{
  if (state == SimpleClient::ClientOnline) {
    ++m_accepted;
    emit accepted(m_accepted);

    SimpleClient *client = qobject_cast<SimpleClient*>(sender());
    if (!client)
      return;

    QVariantMap data;
    data["nick"]     = client->nick();
    data["uniqueId"] = SimpleID::encode(client->uniqueId());
    data["cookie"]   = SimpleID::encode(client->cookie());
    m_authOut.append(data);

    qDebug() << client->nick();
  }
  else if (previousState == SimpleClient::ClientOnline) {
    ++m_disconnected;
    emit disconnected(m_disconnected);
  }
  qDebug() << sender();
}
开发者ID:johnbolia,项目名称:schat,代码行数:24,代码来源:benchmark.cpp

示例11: main

int main(int argc, char *argv[])
{
    if (argc < 2)
	return -1;
    
    SimpleClient client;
    
    if (client.init(argc,argv) == 0)
	{
	ACE_DEBUG((LM_DEBUG,"Cannot init client"));
	return -1;
	}
    client.login();
    
    
    try
	{
	ACS_SHORT_LOG((LM_INFO, "Getting COB: %s", argv[1]));
	acsexmplBuilding::Building_var tower = client.get_object<acsexmplBuilding::Building>(argv[1], 0, true);
	
	
	if (!CORBA::is_nil(tower.in()))
	    {	  
	    ACS_SHORT_LOG((LM_INFO, "Got COB: %s", argv[1]));
	    }
	else
	    {
	    ACS_SHORT_LOG((LM_INFO, "Unable to access COB: %s", argv[1]));
	    }
	}
    catch( CORBA::Exception &ex )
	{
	ACE_PRINT_EXCEPTION (ex, "main");
	}
    
    try
	{
	ACS_SHORT_LOG((LM_INFO,"Releasing..."));
	client.manager()->release_component(client.handle(), argv[1]);
	client.logout();
	}
    catch( CORBA::Exception &_ex )
	{
	ACE_PRINT_EXCEPTION (_ex, "main");
	}
    
    ACE_OS::sleep(3);
    return 0;
}
开发者ID:flyingfrog81,项目名称:ACS,代码行数:49,代码来源:acsexmplClientTower.cpp

示例12: main

/** @cond
*/    
int main(int argc, char *argv[]) 
{
    //Checks command-line arguments
    if (argc < 2)
	{
	ACS_SHORT_LOG((LM_INFO, "Usage: %s <component name> <options>", argv[0]));
	return -1;
	}
    else
	{
	ACS_SHORT_LOG((LM_INFO, "Welcome to %s!", argv[0]));
	}
    
    //Creates and initialyses the SimpleClient object
    SimpleClient client;
    if (client.init(argc,argv) == 0)
	{
	ACE_DEBUG((LM_DEBUG,"Cannot init client"));
	return -1;
	}
    else
	{
	//Must log into manager before we can really do anything
	client.login();
	}
    
    try
	{
	//Gets from manager the reference to the requested component.
	//Pay special attention that this reference is just a generic
	//CORBA object at this point.
	ACS_SHORT_LOG((LM_INFO, "Looking for Object '%s' ", argv[1]));
        CORBA::Object_var obj =  client.getComponent(argv[1], 0 , true);
	
	//Get the stringified IOR of the component.  The IOR of CORBA objects
	//can be considered to be a unique "phone number" used to access CORBA
	//servants.
	ACS_SHORT_LOG((LM_INFO, "Getting stringified IOR"));
	CORBA::String_var mior = client.getORB()->object_to_string(obj.in());    
	
	//Print the IOR to standard out
	u_int result;         
	ACS_SHORT_LOG ((LM_INFO, "IOR for %s is: %s", argv[1], mior.in()));
	result = ACE_OS::printf ("%s", mior.in());
	}
    catch(maciErrType::CannotGetComponentExImpl &_ex)
	{
	_ex.log();
	return -1;
	}
    catch(...)
	{
	ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__, 
							"main");
	
	uex.log();
	return -1;
	}

    //Normally you would not want to have separate try sections for releasing
    //the components and logging out from manager.  This is a very special case 
    //since we do not know ahead of time what will be released.  In other words,
    //argv[1] could technically be "manager" which would end up raising a 
    //no-permission exception.  To get around this just use separate try/catch 
    //sections and ignore no-permission exceptions.
    try
	{
	//All clients must cleanly release objects they activate!
	client.releaseComponent(argv[1]);
	}
    catch(maciErrType::CannotReleaseComponentExImpl &_ex)
	{
	_ex.log();
	return -1;
	}
    catch(...)
	{
	ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__, 
							"main");
	uex.log();
	return -1;
	}
    
    try
	{
	if (client.logout() == 0)
	    {
	    ACS_SHORT_LOG ((LM_INFO, "Cannot logout"));
	    return -1;
	    }
	}
    catch(...)
	{
	ACS_SHORT_LOG((LM_ERROR, "Exception caught"));
	return -1;
	}    
    
    ACS_SHORT_LOG((LM_INFO,"The end!"));
//.........这里部分代码省略.........
开发者ID:ACS-Community,项目名称:ACS,代码行数:101,代码来源:acsexmplClientComponentIOR.cpp

示例13: main

int main(int argc, char *argv[])
{
    SimpleClient client;

    if (client.init(argc,argv) == 0)
    {
        return -1;
    }
    else
    {
        client.login();
    }

    try
    {
        bulkdata::BulkDataSender_var sender = client.get_object<bulkdata::BulkDataSender>("BulkDataNotifSender", 0, true);
        if (CORBA::is_nil(sender.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifSender component"));
            return -1;
        }

        bulkdata::BulkDataDistributer_var distributer = client.get_object<bulkdata::BulkDataDistributer>("BulkDataNotifDistributer", 0, true);
        if (CORBA::is_nil(distributer.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifDistributer component"));
            return -1;
        }

        bulkdata::BulkDataReceiver_var receiver = client.get_object<bulkdata::BulkDataReceiver>("BulkDataNotifReceiver", 0, true);
        if (CORBA::is_nil(receiver.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifReceiver component"));
            return -1;
        }

        bulkdata::BulkDataReceiver_var receiver1 = client.get_object<bulkdata::BulkDataReceiver>("BulkDataNotifReceiver1", 0, true);
        if (CORBA::is_nil(receiver1.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifReceiver1 component"));
            return -1;
        }


// Receiver connected to the Distributor

        sender->connect(distributer.in());

        distributer->multiConnect(receiver.in());

        // instantiate and activate user callbacks for the notification
        BulkDataTestNotificationCb *notifCb = new BulkDataTestNotificationCb();
        ACS::CBvoid_var cb = notifCb->_this();

        // subscribe to the notification mechanism
        distributer->subscribeNotification(cb);


        sender->startSend();

        sender->paceData();

        sender->stopSend();


        sender->disconnect();

        distributer->closeReceiver();

        distributer->multiDisconnect(receiver.in());

        notifCb->_remove_ref();



// Receiver 1 connected directly to the Sender

        sender->connect(receiver1.in());

        // instantiate and activate user callbacks for the notification
        BulkDataTestNotificationCb *notifCb1 = new BulkDataTestNotificationCb();
        ACS::CBvoid_var cb1 = notifCb1->_this();

        // subscribe to the notification mechanism
        receiver1->subscribeNotification(cb1);


        sender->startSend();

        sender->paceData();

        sender->stopSend();


        sender->disconnect();

        receiver1->closeReceiver();

        notifCb1->_remove_ref();
    }
//.........这里部分代码省略.........
开发者ID:jantogni,项目名称:ACS,代码行数:101,代码来源:bulkDataNotificationTest.cpp

示例14: main

/**
 * A client to send alarms: it expects to find the number of alarm to send
 * as a parameter in the command line.
 * As an option, it is also possible to set in the command line the
 * fault family and the fault member.
 * By default the fault family is "ALCLIENT" and the Fault Member is (ALARM).
 * The fault code is always set to 1.
 * For each alarm to send a triplet like <ALCLIENT, ALARM_1, 1> is created.
 * <P>
 * For each alarm, the process activates it and then terminates it.
 * First all the alarms are activated then terminated.
 * <P>
 * The purposes of this process are:
 * <UL>
 * 	<LI>Check if sending alarms from a client works
 * 	<LI>have a client that sends alarms from the command line
 *  <LI>allow to investigate problems in the sources without the complexity of the container
 * <UL>
 */
int main(int argc, char *argv[])
{
    // Checks command-line arguments.
    if (argc !=2 && argc!=4)
	{
	ACS_SHORT_LOG((LM_INFO, "Usage: %s <num. of alarms to send> [<FaultFamily Fault_Member>]", argv[0]));
	return -1;
	}
    
    //Creates and initializes the SimpleClient object
    SimpleClient client;
    if (client.init(argc,argv) == 0)
	{
	ACE_DEBUG((LM_DEBUG,"Cannot init client"));
	return -1;
	}
    else
	{
	//Must log into manager before we can really do anything
	client.login();
	}

    // Get the number of alarms to send
    int alarmsToSend = (int)strtof(argv[1],NULL);
    if (alarmsToSend==0) {
    	// It can happen if the user set 0 as param or if the conversion made
    	// by strtof failed
    	ACS_SHORT_LOG((LM_ERROR, "%d alarms to send: nothing to do. Check val of first param (%s). Is it a number?", alarmsToSend,argv[1]));
    	return -1;
    }

    // Init the alarm system factory
    ACSAlarmSystemInterfaceFactory::init(client.manager());
    ACS_SHORT_LOG((LM_DEBUG, "ACSAlarmSystemInterfaceFactory initialized"));

    std::string FF="ALCLIENT";
    std::string FM="ALARM";
    const int FC=1;
    if (argc==4) {
    	FF=argv[2];
    	FM=argv[3];
    }
    ACS_SHORT_LOG((LM_INFO, "Generating %d alarms with triplets like <%s, %s_n, 1>", alarmsToSend,FF.c_str(), FM.c_str()));

    // create the AlarmSystemInterface
 	auto_ptr<acsalarm::AlarmSystemInterface> alarmSource(ACSAlarmSystemInterfaceFactory::createSource());
 	ACS_SHORT_LOG((LM_DEBUG, "Source created"));

 	ACS_SHORT_LOG((LM_INFO, "Sending ACTIVE alarms"));
 	for (int t=0; t<alarmsToSend; t++) {
 		char tempStr[8];
 		sprintf(tempStr,"%d",t);
 		std::string fmTosend=FM;
 		fmTosend+='_';
 		fmTosend+=tempStr;
 		sendAlarm(alarmSource.get(),FF,fmTosend,FC,true);
 	}

 	sleep(5);

 	ACS_SHORT_LOG((LM_INFO, "Sending TERMINATE alarms"));
 	for (int t=0; t<alarmsToSend; t++) {
 		char tempStr[8];
 		sprintf(tempStr,"%d",t);
		std::string fmTosend=FM;
		fmTosend+='_';
		fmTosend+=tempStr;
		sendAlarm(alarmSource.get(),FF,fmTosend,FC,false);
	}
 	auto_ptr<acsalarm::AlarmSystemInterface> tstSource(ACSAlarmSystemInterfaceFactory::createSource());

// 	ACSAlarmSystemInterfaceFactory::done();

 	client.logout();

 	ACS_SHORT_LOG((LM_INFO, "%s done.",argv[0]));
    return 0;
}
开发者ID:flyingfrog81,项目名称:ACS,代码行数:97,代码来源:alarmSystemClient.cpp

示例15: main

int main(int argc, char *argv[])
{

    ACS::TimeInterval samplingFrequency;
    ACS::TimeInterval reportRate;

    if (argc == 3)
	{
	samplingFrequency=atoll(argv[1]);
	reportRate=atoll(argv[2]);
	}
    else if (argc == 1)
	{
	samplingFrequency=1000000;
	reportRate=10000000;
	}
    else
	{
	ACS_SHORT_LOG((LM_INFO, "usage: acssampOnlyNCServer <sampFrequency> <reportRate>"));
	cout << endl;
	return -1;
	}

    cout << "used value >> samplingFrequency: " << samplingFrequency 
	 << "; reportRate: " << reportRate << endl;

    signal(SIGINT,stopLoop);

    /// Creates and initializes the SimpleClient object
    SimpleClient client;
    if (!client.init(argc,argv))
	{
	return -1;
	}
    else
	{
	client.login();
	}
    
    
    ACS_SHORT_LOG((LM_INFO, "Getting Component"));

    try
	{
	
        // obtain the reference to the SAMP (factory) object
        acssamp::Samp_var foo = client.get_object<acssamp::Samp>("SAMP1", 0, true);

	if (!CORBA::is_nil(foo.in()))
	    {

	    ACS_SHORT_LOG((LM_DEBUG, "Got samp descriptor()."));

	    // calls the initSampObj to create dynamically a new sampling object
	    acssamp::SampObj_ptr fooNew = 
		foo->initSampObj("LAMP1","brightness",samplingFrequency,reportRate);

	    ACS_SHORT_LOG((LM_INFO,"*** Start to sample ***"));

	    ACS_SHORT_LOG((LM_INFO,"Not Channel: %s",fooNew->getChannelName()));
	  
	  
	    ACS_SHORT_LOG((LM_INFO,"Sleeping 15 seconds to allow NC Client connection ..."));
	    ACE_OS::sleep(15);
	    ACS_SHORT_LOG((LM_INFO," ... done"));


	    // starts the sampling
	    fooNew->start();

	    cout << "Infinite loop started; press Ctrl-C to stop it ..." << endl;
	    while(endme)
		ACE_OS::sleep(1);
	    cout << "... out of the loop!" << endl;

	    // stop and clen-up everything
	    fooNew->stop();
	    ACE_OS::sleep(2);
	    fooNew->destroy();

	    CORBA::release(fooNew);

	    }	
	} /* end main try */
    catch (OutOfBoundsEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "OutOfBoundsEx exception catched !"));
	OutOfBoundsExImpl err(ex);
	err.log();
	}
    catch (CouldntAccessComponentEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "CouldntAccessComponentEx exception catched !"));
	CouldntAccessComponentExImpl err(ex);
	err.log();
	}
    catch (CouldntAccessPropertyEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "CouldntAccessPropertyEx exception catched !"));
	CouldntAccessPropertyExImpl err(ex);
//.........这里部分代码省略.........
开发者ID:franciscobeltran,项目名称:ACS,代码行数:101,代码来源:acssampPerfServer.cpp


注:本文中的SimpleClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。