Go to the documentation of this file.00001 #ifndef _QmfEngineResilientConnection_
00002 #define _QmfEngineResilientConnection_
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #include <qmf/engine/Message.h>
00024 #include <qmf/engine/ConnectionSettings.h>
00025 #include <string>
00026 
00027 namespace qmf {
00028 namespace engine {
00029 
00030     class ResilientConnectionImpl;
00031 
00035     struct ResilientConnectionEvent {
00036         enum EventKind {
00037             CONNECTED      = 1,
00038             DISCONNECTED   = 2,
00039             SESSION_CLOSED = 3,
00040             RECV           = 4
00041         };
00042 
00043         EventKind kind;
00044         void*     sessionContext; 
00045         char*     errorText;      
00046         Message   message;        
00047     };
00048 
00049     class SessionHandle {
00050         friend class ResilientConnectionImpl;
00051         void* impl;
00052     };
00053 
00062     class ResilientConnection {
00063     public:
00064 
00072         ResilientConnection(const ConnectionSettings& settings);
00073         ~ResilientConnection();
00074 
00079         bool isConnected() const;
00080 
00086         bool getEvent(ResilientConnectionEvent& event);
00087 
00092         void popEvent();
00093 
00103         bool createSession(const char* name, void* sessionContext, SessionHandle& handle);
00104 
00109         void destroySession(SessionHandle handle);
00110 
00116         void sendMessage(SessionHandle handle, Message& message);
00117 
00123         void declareQueue(SessionHandle handle, char* queue);
00124 
00130         void deleteQueue(SessionHandle handle, char* queue);
00131 
00139         void bind(SessionHandle handle, char* exchange, char* queue, char* key);
00140 
00148         void unbind(SessionHandle handle, char* exchange, char* queue, char* key);
00149 
00156         void setNotifyFd(int fd);
00157 
00164         void notify();
00165 
00166     private:
00167         ResilientConnectionImpl* impl;
00168     };
00169 }
00170 }
00171 
00172 #endif
00173