00001 ////////////////////////////////////////////////////////////////////////// 00002 // // 00003 // XrdClientUnsolMsg // 00004 // // 00005 // Author: Fabrizio Furano (INFN Padova, 2004) // 00006 // Adapted from TXNetFile (root.cern.ch) originally done by // 00007 // Alvise Dorigo, Fabrizio Furano // 00008 // INFN Padova, 2003 // 00009 // // 00010 // Base classes for unsolicited msg senders/receivers // 00011 // // 00012 ////////////////////////////////////////////////////////////////////////// 00013 00014 // $Id: XrdClientUnsolMsg.hh 22437 2008-03-04 14:35:16Z rdm $ 00015 00016 #ifndef XRC_UNSOLMSG_H 00017 #define XRC_UNSOLMSG_H 00018 00019 class XrdClientMessage; 00020 class XrdClientUnsolMsgSender; 00021 00022 // The processing result for an unsolicited response 00023 enum UnsolRespProcResult { 00024 kUNSOL_CONTINUE = 0, // Dispatching must continue to other interested handlers 00025 kUNSOL_KEEP, // Dispatching ended, but stream still alive (must keep the SID) 00026 kUNSOL_DISPOSE // Dispatching ended, stream no more to be used 00027 }; 00028 00029 // Handler 00030 00031 class XrdClientAbsUnsolMsgHandler { 00032 public: 00033 00034 virtual ~XrdClientAbsUnsolMsgHandler() { } 00035 // To be called when an unsolicited response arrives from the lower layers 00036 virtual UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender, 00037 XrdClientMessage *unsolmsg) = 0; 00038 00039 }; 00040 00041 // Sender 00042 00043 class XrdClientUnsolMsgSender { 00044 00045 public: 00046 00047 virtual ~XrdClientUnsolMsgSender() { } 00048 00049 // The upper level handler for unsolicited responses 00050 XrdClientAbsUnsolMsgHandler *UnsolicitedMsgHandler; 00051 00052 inline UnsolRespProcResult SendUnsolicitedMsg(XrdClientUnsolMsgSender *sender, XrdClientMessage *unsolmsg) { 00053 // We simply send the event 00054 if (UnsolicitedMsgHandler) 00055 return (UnsolicitedMsgHandler->ProcessUnsolicitedMsg(sender, unsolmsg)); 00056 00057 return kUNSOL_CONTINUE; 00058 } 00059 00060 inline XrdClientUnsolMsgSender() { UnsolicitedMsgHandler = 0; } 00061 }; 00062 00063 #endif