j***@gmail.com
2014-12-18 19:41:58 UTC
Hi everyone, I hope anyone can help me with this since I'm a newbie in CORBA.
I'm trying to implement a simple callback but the client callback is never called. Below is the code, thanks in advanced
<SERVER CODE>=======================================================
CommunicatorManager::CommunicatorManager()
{
m_drvCommunicator = new CoreLogon_Impl();
int argc=0;
char** argv = nullptr;
CORBAreference = CORBA::ORB_init(argc, argv);
ORBrootReference =
CORBAreference->resolve_initial_references("RootPOA");
ORBpoa = PortableServer::POA::_narrow( ORBrootReference.in() );
RequestSenialesID = ORBpoa->activate_object( m_drvCommunicator );
RestSenialesReference = m_drvCommunicator->_this();
_orbNC = CORBAreference->resolve_initial_references("NameService");
if( CORBA::is_nil( _orbNC.in() ) )
{
cout << "No puede encontrarse el servidor de nombre" << endl;
}
CORBAnameServer = CosNaming::NamingContext::_narrow( _orbNC.in() );
if( CORBA::is_nil(CORBAnameServer.in()) )
{
cout << "No puede accederse al servidor de nombre" << endl;
}
name.length(1);
name[0].id=CORBA::string_dup("CoreLogon");
CORBAnameServer->rebind(name, RestSenialesReference);
m_drvCommunicator->_remove_ref();
pmgr = ORBpoa->the_POAManager();
pmgr->activate();
m_runningThread = new std::thread(
[&]()
{
CORBAreference->run();
}
);
}
--------------------------------------------------------------
bool CoreLogon_Impl::LoginClient(const ::CORBACommunication::UserData& user,
::CORBACommunication::ClientProxy_ptr client)
{
cout << endl << endl << "LOGIN received from GUI - USUSER: "
<<user.user<< " - PASS: " <<user.password<< endl << endl;
registeredClient = ::CORBACommunication::ClientProxy::_duplicate(client);
new std::thread(
[&]()
{
::CORBACommunication::Alarm a;
a.alrmTpy = ::CORBACommunication::AlarmType::LOW;
a.radar = CORBA::string_dup("RADAR-ID-1");
a.subsystem = CORBA::string_dup("SUB/SYS/TEM");
a.variable = CORBA::string_dup("VARIABLE1");
registeredClient->ReceiveAlarm(a);
}
);
return true;
}
<CLIENT CODE>==========================================================
CoreLogonWrapper::CoreLogonWrapper()
{
int argc = 0;
char** argv = NULL;
orb = CORBA::ORB_init(argc, argv);
obj = orb->resolve_initial_references("NameService");
if( CORBA::is_nil(obj.in()) )
cout << "ERROR";
m_nc = CosNaming::NamingContext::_narrow( obj.in() );
if( CORBA::is_nil(obj.in()) )
cout << "ERROR";
m_corbaCosName.length(1);
m_corbaCosName[0].id = CORBA::string_dup("CoreLogon");
m_remoteObjRef = m_nc->resolve(m_corbaCosName);
if( CORBA::is_nil(m_remoteObjRef.in()) )
cout << "ERROR";
m_orbvarCoreLogon = ::CORBACommunication::CoreLogon::_narrow( m_remoteObjRef.in() );
if( CORBA::is_nil(m_orbvarCoreLogon.in()) )
cout << "ERROR" << endl;
m_runningThread = new std::thread(
[&]()
{
orb->run();
}
);
}
-----------------------------------------------------------
bool CoreLogonWrapper::Login(string user, string password)
{
bool resultLogin = false;
::CORBACommunication::UserData strUserData;
strUserData.user = user.c_str();
strUserData.password = password.c_str();
m_clientProxy = new ClientProxy_Impl();
::CORBACommunication::ClientProxy_var remotePtr= m_clientProxy->_this();
resultLogin = m_orbvarCoreLogon->LoginClient(strUserData, remotePtr);
if(resultLogin)
cout <<endl<<endl << "Entramos..." << endl;
else
cout <<endl<<endl << "Remotamos..." << endl;
return true;
}
-------------------------------------------------------------
void ClientProxy_Impl::ReceiveTelemetry( const
::CORBACommunication::TelemetryIdlItem& telemetryItem )
{
cout << endl << "TELEMETRIA recibida desde el CORE" << endl;
}
I'm trying to implement a simple callback but the client callback is never called. Below is the code, thanks in advanced
<SERVER CODE>=======================================================
CommunicatorManager::CommunicatorManager()
{
m_drvCommunicator = new CoreLogon_Impl();
int argc=0;
char** argv = nullptr;
CORBAreference = CORBA::ORB_init(argc, argv);
ORBrootReference =
CORBAreference->resolve_initial_references("RootPOA");
ORBpoa = PortableServer::POA::_narrow( ORBrootReference.in() );
RequestSenialesID = ORBpoa->activate_object( m_drvCommunicator );
RestSenialesReference = m_drvCommunicator->_this();
_orbNC = CORBAreference->resolve_initial_references("NameService");
if( CORBA::is_nil( _orbNC.in() ) )
{
cout << "No puede encontrarse el servidor de nombre" << endl;
}
CORBAnameServer = CosNaming::NamingContext::_narrow( _orbNC.in() );
if( CORBA::is_nil(CORBAnameServer.in()) )
{
cout << "No puede accederse al servidor de nombre" << endl;
}
name.length(1);
name[0].id=CORBA::string_dup("CoreLogon");
CORBAnameServer->rebind(name, RestSenialesReference);
m_drvCommunicator->_remove_ref();
pmgr = ORBpoa->the_POAManager();
pmgr->activate();
m_runningThread = new std::thread(
[&]()
{
CORBAreference->run();
}
);
}
--------------------------------------------------------------
bool CoreLogon_Impl::LoginClient(const ::CORBACommunication::UserData& user,
::CORBACommunication::ClientProxy_ptr client)
{
cout << endl << endl << "LOGIN received from GUI - USUSER: "
<<user.user<< " - PASS: " <<user.password<< endl << endl;
registeredClient = ::CORBACommunication::ClientProxy::_duplicate(client);
new std::thread(
[&]()
{
::CORBACommunication::Alarm a;
a.alrmTpy = ::CORBACommunication::AlarmType::LOW;
a.radar = CORBA::string_dup("RADAR-ID-1");
a.subsystem = CORBA::string_dup("SUB/SYS/TEM");
a.variable = CORBA::string_dup("VARIABLE1");
registeredClient->ReceiveAlarm(a);
}
);
return true;
}
<CLIENT CODE>==========================================================
CoreLogonWrapper::CoreLogonWrapper()
{
int argc = 0;
char** argv = NULL;
orb = CORBA::ORB_init(argc, argv);
obj = orb->resolve_initial_references("NameService");
if( CORBA::is_nil(obj.in()) )
cout << "ERROR";
m_nc = CosNaming::NamingContext::_narrow( obj.in() );
if( CORBA::is_nil(obj.in()) )
cout << "ERROR";
m_corbaCosName.length(1);
m_corbaCosName[0].id = CORBA::string_dup("CoreLogon");
m_remoteObjRef = m_nc->resolve(m_corbaCosName);
if( CORBA::is_nil(m_remoteObjRef.in()) )
cout << "ERROR";
m_orbvarCoreLogon = ::CORBACommunication::CoreLogon::_narrow( m_remoteObjRef.in() );
if( CORBA::is_nil(m_orbvarCoreLogon.in()) )
cout << "ERROR" << endl;
m_runningThread = new std::thread(
[&]()
{
orb->run();
}
);
}
-----------------------------------------------------------
bool CoreLogonWrapper::Login(string user, string password)
{
bool resultLogin = false;
::CORBACommunication::UserData strUserData;
strUserData.user = user.c_str();
strUserData.password = password.c_str();
m_clientProxy = new ClientProxy_Impl();
::CORBACommunication::ClientProxy_var remotePtr= m_clientProxy->_this();
resultLogin = m_orbvarCoreLogon->LoginClient(strUserData, remotePtr);
if(resultLogin)
cout <<endl<<endl << "Entramos..." << endl;
else
cout <<endl<<endl << "Remotamos..." << endl;
return true;
}
-------------------------------------------------------------
void ClientProxy_Impl::ReceiveTelemetry( const
::CORBACommunication::TelemetryIdlItem& telemetryItem )
{
cout << endl << "TELEMETRIA recibida desde el CORE" << endl;
}