4 * @author Carlos O'Ryan <coryan@uci.edu>
8 #include "RTServer_Setup.h"
9 #include "RIR_Narrow.h"
10 #include "Servant_var.h"
11 #include "RTEC_Initializer.h"
12 #include "EC_Destroyer.h"
13 #include "Auto_Disconnect.h"
16 #include "orbsvcs/Event/EC_Event_Channel.h"
17 #include "orbsvcs/Event/EC_Gateway_IIOP.h"
19 Peer_Base::Peer_Base (CORBA::ORB_ptr orb
,
20 RTServer_Setup
&rtserver_setup
)
21 : orb_ (CORBA::ORB::_duplicate (orb
))
22 , poa_ (rtserver_setup
.poa ())
24 Servant_var
<TAO_EC_Event_Channel
> ec_impl (
25 RTEC_Initializer::create (this->poa_
.in (),
27 rtserver_setup
.rtcorba_setup ())
32 PortableServer::ObjectId_var ec_id
=
33 this->poa_
->activate_object (ec_impl
.in ());
34 CORBA::Object_var ec_object
=
35 this->poa_
->id_to_reference (ec_id
.in ());
37 this->event_channel_
=
38 RtecEventChannelAdmin::EventChannel::_narrow (ec_object
.in ());
41 Peer_Base::~Peer_Base (void)
46 Peer_Base::shutdown (void)
49 EC_Destroyer
ec_destroyer (this->event_channel_
.in ());
50 this->event_channel_
=
51 RtecEventChannelAdmin::EventChannel::_nil ();
54 this->orb_
->shutdown (0);
58 Peer_Base::channel (void)
60 return CORBA::Object::_duplicate (this->event_channel_
.in ());
64 Peer_Base::connect (Federated_Test::Peer_ptr remote_peer
)
66 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) Connecting....\n"));
67 CORBA::Object_var remote_ec_object
=
68 remote_peer
->channel ();
70 RtecEventChannelAdmin::EventChannel_var remote_ec
=
71 RtecEventChannelAdmin::EventChannel::_narrow (remote_ec_object
.in ());
73 Servant_var
<TAO_EC_Gateway_IIOP
> gateway (new TAO_EC_Gateway_IIOP
);
74 gateway
->init (remote_ec
.in (),
75 this->event_channel_
.in ());
77 RtecEventChannelAdmin::Observer_var observer
=
80 RtecEventChannelAdmin::Observer_Handle h
=
81 this->event_channel_
->append_observer (observer
.in ());
83 gateway
->observer_handle (h
);
86 Federated_Test::Loopback_ptr
87 Peer_Base::setup_loopback (CORBA::Long experiment_id
,
88 CORBA::Long base_event_type
)
90 Servant_var
<Loopback
> loopback (
91 new Loopback (experiment_id
,
95 this->event_channel_
.in ()));
97 Auto_Disconnect
<Loopback
> disconnect (loopback
);
99 Federated_Test::Loopback_var lb
=
102 disconnect
.release ();
107 PortableServer::POA_ptr
108 Peer_Base::_default_POA (void)
110 return PortableServer::POA::_duplicate (this->poa_
.in ());