您的位置:首页 > 其它

测试一下用Live Writer发日志到student.csdn

2009-06-12 10:25 274 查看
下面是代码测试
#include "MessengerC.h"
#include <iostream>
#include "tao/Messaging/Messaging.h" 
#include "tao/Messaging/TAO_ExtC.h" 

#include "ace/Profile_Timer.h" 
ACE_Profile_Timer timer;         //?¨ê±?÷
TimeBase::TimeT timeout = 6*1000*10000; //3?ê±??

int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  try {
    // Initialize the ORB.
    CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );

    // Read and destringify the Messenger object/'s IOR.
    CORBA::Object_var obj = orb->string_to_object( "file://Messenger.ior" );
    if( CORBA::is_nil( obj.in() ) ) {
      std::cerr << "Could not get Messenger IOR." << std::endl;
      return 1;
    }

	//??è?ORBμ?2??????ó
	CORBA::Object_var object = orb->resolve_initial_references(
		"PolicyCurrent");
	CORBA::PolicyCurrent_var policy_current =
		CORBA::PolicyCurrent::_narrow(object.in());

	//éè??3?ê±2?êy
	CORBA::Any anyTm;
	anyTm <<=timeout;

	//éè??ORB2???
	CORBA::PolicyList policy_list(1);
	policy_list.length(1);
	policy_list[0] = orb->create_policy(Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,anyTm);

	policy_current->set_policy_overrides(policy_list,CORBA::ADD_OVERRIDE);

	policy_list[0]->destroy();

	timer.start();

	try 
	{

		// Narrow the IOR to a Messenger object reference.
		Messenger_var messenger = Messenger::_narrow( obj.in() );
		if( CORBA::is_nil( messenger.in() ) ) {
			std::cerr << "IOR was not a Messenger object reference." << std::endl;
			return 1;
		}

		// Send a message the the Messenger object.
		CORBA::String_var msg = CORBA::string_dup( "Hello!" );
		messenger->send_message( "TAO User", "TAO Test", msg.inout() );

		// Print the Messenger/'s reply.
		std::cout << "Reply: " << msg.in() << std::endl;
	}
	catch (...)
	{
		timer.stop();
		ACE_Profile_Timer::ACE_Elapsed_Time el; 
		timer.elapsed_time (el); 
		printf("elapse time is %d//n", el.real_time); 

	}

    return 0;
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "CORBA exception: " << ex << std::endl;
  }
   
  return 1;
}


 

下面是图片测试
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: