00001 // Peer.cpp,v 1.16 2006/03/14 06:14:34 jtc Exp 00002 00003 #include "orbsvcs/Notify/Peer.h" 00004 00005 ACE_RCSID(Notify, TAO_Notify_Peer, "Peer.cpp,v 1.16 2006/03/14 06:14:34 jtc Exp") 00006 00007 #include "orbsvcs/Notify/Proxy.h" 00008 00009 #include "tao/debug.h" 00010 00011 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00012 00013 TAO_Notify_Peer::TAO_Notify_Peer (void) 00014 { 00015 } 00016 00017 TAO_Notify_Peer::~TAO_Notify_Peer () 00018 { 00019 } 00020 00021 void 00022 TAO_Notify_Peer::qos_changed (const TAO_Notify_QoSProperties& /*qos_properties*/) 00023 { 00024 // NOP. 00025 } 00026 00027 void 00028 TAO_Notify_Peer::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00029 { 00030 // NOP. 00031 } 00032 00033 void 00034 TAO_Notify_Peer::handle_dispatch_exception (ACE_ENV_SINGLE_ARG_DECL) 00035 { 00036 // Sever all association when a remote client misbehaves. Other strategies like reties are possible but not implemented. 00037 this->proxy ()->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); 00038 } 00039 00040 void 00041 TAO_Notify_Peer::dispatch_updates (const TAO_Notify_EventTypeSeq & added, const TAO_Notify_EventTypeSeq & removed ACE_ENV_ARG_DECL) 00042 { 00043 TAO_Notify_EventTypeSeq subscribed_types ; 00044 this->proxy ()->subscribed_types (subscribed_types ACE_ENV_ARG_PARAMETER); 00045 ACE_CHECK; 00046 00047 ACE_TRY 00048 { 00049 CosNotification::EventTypeSeq cos_added; 00050 CosNotification::EventTypeSeq cos_removed; 00051 00052 const TAO_Notify_EventType& special = TAO_Notify_EventType::special (); 00053 00054 // Don;t inform of types that we already know about. 00055 // E.g. if we're subscribed for {A,B,C,F} 00056 // and we receive an update with added list {A,B,G} 00057 // then, we should only send {G} because peer already knows about {A, B} 00058 // However if we're subscribed for everything, send all kinds of adds. 00059 00060 // Don;t inform of removed types that we don;t care about. 00061 // e.g. if we're currently subscribed for {A,B,C,F} 00062 // and we receive an update with removed list {A, B, D} 00063 // then, we should only send {A,B} because the peer is not interested in D. 00064 // However if we're subscribed for everything, send all kinds of removes. 00065 00066 TAO_Notify_EventTypeSeq added_result = added; 00067 TAO_Notify_EventTypeSeq removed_result; 00068 00069 if (subscribed_types.find (special) != 0) 00070 { 00071 added_result.remove_seq (subscribed_types); 00072 removed_result.intersection (subscribed_types, removed); 00073 } 00074 else 00075 { 00076 removed_result = removed; 00077 } 00078 00079 added_result.populate_no_special (cos_added); 00080 removed_result.populate_no_special (cos_removed); 00081 00082 if (cos_added.length () != 0 || cos_removed.length () != 0) 00083 { 00084 // Protect this object from being destroyed in this scope. 00085 TAO_Notify_Proxy::Ptr proxy_guard(this->proxy ()); 00086 00087 this->dispatch_updates_i (cos_added, cos_removed ACE_ENV_ARG_PARAMETER); 00088 ACE_TRY_CHECK; 00089 } 00090 } 00091 ACE_CATCH (CORBA::OBJECT_NOT_EXIST, not_exist) 00092 { 00093 this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); 00094 ACE_TRY_CHECK; 00095 } 00096 ACE_CATCH (CORBA::NO_IMPLEMENT, no_impl) 00097 { 00098 // The peer does not implement the offer/subscription_change method 00099 // Do nothing. Later, perhaps set a flag that helps us decide if we should dispatch_updates_i. 00100 } 00101 ACE_CATCH (CORBA::SystemException, sysex) 00102 { 00103 this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); 00104 ACE_TRY_CHECK; 00105 } 00106 ACE_CATCHANY 00107 { 00108 // Do nothing 00109 } 00110 ACE_ENDTRY; 00111 } 00112 00113 CORBA::ULong 00114 TAO_Notify_Peer::_incr_refcnt (void) 00115 { 00116 return this->proxy ()->_incr_refcnt (); 00117 } 00118 00119 CORBA::ULong 00120 TAO_Notify_Peer::_decr_refcnt (void) 00121 { 00122 return this->proxy ()->_decr_refcnt (); 00123 } 00124 00125 TAO_END_VERSIONED_NAMESPACE_DECL