00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __WOSH_Bundles_CommunicationManager_Impl_H__
00041 #define __WOSH_Bundles_CommunicationManager_Impl_H__
00042
00043 #include <core/BundleGenericWorker.h>
00044 #include <core/Containers.h>
00045 #include <core/User.h>
00046 #include <core/MessageQueue.h>
00047 #include <core/Notification.h>
00048 #include <framework/communication/NotificationFlow.h>
00049 #include <framework/communication/NotificationConversion.h>
00050 #include <interfaces/communication/Communicator.h>
00051 #include <interfaces/communication/InterpreterService.h>
00052 #include "ICommunicationManagerListener.h"
00053
00054
00055 using namespace wosh;
00056 using namespace wosh::communication;
00057
00058 typedef wosh::XX_MapT<long, NotificationFlow*> tLongNotificationFlowMap
00059
00060 class CommunicationManagerImpl : public BundleGenericWorker
00061 {
00062 public:
00063
00064
00065
00066
00067 CommunicationManagerImpl( BundleGeneric& bundle );
00068
00069
00070
00071
00072 virtual ~CommunicationManagerImpl();
00073
00074
00075 public:
00076
00077 void evalMessage( const Message& message );
00078
00079 NotificationFlow* evalNotification_( const Notification* notification, const Message* message );
00080
00081 bool sendNotification_( NotificationFlow* notification );
00082
00083 void archiveNotification_( NotificationFlow* notification );
00084
00085 protected:
00086
00087 void communicator_reply_sent( WRESULT ret, long notification_id, const URI& source );
00088 void communicator_reply_read( WRESULT ret, long notification_id, const URI& source );
00089
00090
00091 protected:
00092
00093 WRESULT intersectCommunicators_( UserInfoCommmunicators* usrComms, const Notification* notification, const std::string& location );
00094
00095 Interpreter* selectInterpreter_( const Notification* notification, const Communicator* comm );
00096
00097 UserInfoCommmunicators* getCommunicatorsOf( const std::string& username );
00098
00099 bool isInterpreterRequired_( const Notification* notification, const Communicator* comm );
00100
00101
00102
00103
00104
00105 public:
00106
00107 void setListener( ICommunicationManagerListener* list ) { this->listener = list; }
00108
00109 void setFlowTimeOut( long seconds ) { this->flowTimeout = seconds; }
00110 void setFlowRetryTime( long seconds ) { this->flowRetryTime = seconds; }
00111 void setFlowRetryCount( long times ) { this->flowRetryCount = times; }
00112
00113
00114
00115
00116
00117 public:
00118 long getFlowTimeOut() const { return this->flowTimeout; }
00119 long getFlowRetryTime() const { return this->flowRetryTime; }
00120 long getFlowRetryCount() const { return this->flowRetryCount; }
00121
00122 tStrCommunicatorMap& getCommunicators() { return this->comms; }
00123 tStrInterpreterMap& getInterpreters() { return this->transl; }
00124
00125 tLongNotificationFlowMap& getMessages() { return this->messages; }
00126 tLongNotificationFlowMap& getMessagesArchived() { return this->messagesArchived; }
00127
00128
00129
00130
00131
00132 protected:
00133
00134 bool processNotification_( NotificationFlow* notification );
00135
00136
00137
00138
00139
00140
00141 virtual void runThread();
00142
00143
00144 protected:
00145
00146 tStrCommunicatorMap comms;
00147 tStrInterpreterMap transl;
00148
00149 tLongNotificationFlowMap messages;
00150 tLongNotificationFlowMap messagesArchived;
00151 long messageArchiveSize;
00152
00153 long flowTimeout;
00154 long flowRetryTime;
00155 long flowRetryCount;
00156
00157 MessageQueue msgQueue;
00158
00159 ICommunicationManagerListener* listener;
00160
00161
00162 };
00163
00164
00165 #endif //__WOSH_Bundles_CommunicationManager_Impl_H__