00001 // $Id: Peer.cpp 76626 2007-01-26 13:50:03Z elliott_c $ 00002 00003 #include "orbsvcs/Notify/Peer.h" 00004 00005 ACE_RCSID(Notify, TAO_Notify_Peer, "$Id: Peer.cpp 76626 2007-01-26 13:50:03Z elliott_c $") 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 (void) 00029 { 00030 // NOP. 00031 } 00032 00033 void 00034 TAO_Notify_Peer::handle_dispatch_exception (void) 00035 { 00036 // Sever all association when a remote client misbehaves. Other strategies like reties are possible but not implemented. 00037 this->proxy ()->destroy (); 00038 } 00039 00040 void 00041 TAO_Notify_Peer::dispatch_updates (const TAO_Notify_EventTypeSeq & added, const TAO_Notify_EventTypeSeq & removed) 00042 { 00043 TAO_Notify_EventTypeSeq subscribed_types ; 00044 this->proxy ()->subscribed_types (subscribed_types); 00045 00046 try 00047 { 00048 CosNotification::EventTypeSeq cos_added; 00049 CosNotification::EventTypeSeq cos_removed; 00050 00051 const TAO_Notify_EventType& special = TAO_Notify_EventType::special (); 00052 00053 // Don;t inform of types that we already know about. 00054 // E.g. if we're subscribed for {A,B,C,F} 00055 // and we receive an update with added list {A,B,G} 00056 // then, we should only send {G} because peer already knows about {A, B} 00057 // However if we're subscribed for everything, send all kinds of adds. 00058 00059 // Don;t inform of removed types that we don;t care about. 00060 // e.g. if we're currently subscribed for {A,B,C,F} 00061 // and we receive an update with removed list {A, B, D} 00062 // then, we should only send {A,B} because the peer is not interested in D. 00063 // However if we're subscribed for everything, send all kinds of removes. 00064 00065 TAO_Notify_EventTypeSeq added_result = added; 00066 TAO_Notify_EventTypeSeq removed_result; 00067 00068 if (subscribed_types.find (special) != 0) 00069 { 00070 added_result.remove_seq (subscribed_types); 00071 removed_result.intersection (subscribed_types, removed); 00072 } 00073 else 00074 { 00075 removed_result = removed; 00076 } 00077 00078 added_result.populate_no_special (cos_added); 00079 removed_result.populate_no_special (cos_removed); 00080 00081 if (cos_added.length () != 0 || cos_removed.length () != 0) 00082 { 00083 // Protect this object from being destroyed in this scope. 00084 TAO_Notify_Proxy::Ptr proxy_guard(this->proxy ()); 00085 00086 this->dispatch_updates_i (cos_added, cos_removed); 00087 } 00088 } 00089 catch (const CORBA::OBJECT_NOT_EXIST&) 00090 { 00091 this->handle_dispatch_exception (); 00092 } 00093 catch (const CORBA::NO_IMPLEMENT&) 00094 { 00095 // The peer does not implement the offer/subscription_change method 00096 // Do nothing. Later, perhaps set a flag that helps us decide if we should dispatch_updates_i. 00097 } 00098 catch (const CORBA::SystemException&) 00099 { 00100 this->handle_dispatch_exception (); 00101 } 00102 catch (const CORBA::Exception&) 00103 { 00104 // Do nothing 00105 } 00106 } 00107 00108 CORBA::ULong 00109 TAO_Notify_Peer::_incr_refcnt (void) 00110 { 00111 return this->proxy ()->_incr_refcnt (); 00112 } 00113 00114 CORBA::ULong 00115 TAO_Notify_Peer::_decr_refcnt (void) 00116 { 00117 return this->proxy ()->_decr_refcnt (); 00118 } 00119 00120 TAO_END_VERSIONED_NAMESPACE_DECL