libmoost
/home/mhx/git/github/libmoost/src/mq/stomp_client.cpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #include "../../include/moost/mq/stomp_client.h"
00029 #include "stomp_client_impl.h"
00030 
00031 namespace moost { namespace mq {
00032 
00033 stomp_client::stomp_client(size_t consumer_pool_size,
00034                            const boost::posix_time::time_duration& keepalive_interval,
00035                            const boost::posix_time::time_duration& reconnect_interval)
00036    : m_impl(new impl(consumer_pool_size, keepalive_interval, reconnect_interval))
00037 {
00038 }
00039 
00040 stomp_client::~stomp_client()
00041 {
00042    try
00043    {
00044       disconnect();
00045    }
00046    catch (...)
00047    {
00048    }
00049 }
00050 
00051 void stomp_client::connect(const std::string& hostname, int port, boost::function<void (const boost::system::error_code&, const std::string&)> error_cb)
00052 {
00053    m_impl->connect(hostname, port, error_cb);
00054 }
00055 
00056 void stomp_client::disconnect()
00057 {
00058    if (is_connected())
00059    {
00060       m_impl->disconnect();
00061    }
00062 }
00063 
00064 void stomp_client::subscribe(const std::string& topic, boost::function<void (const std::string&)> message_cb, ack::type ack_type,
00065                              const boost::posix_time::time_duration& max_msg_interval)
00066 {
00067    m_impl->subscribe(topic, message_cb, ack_type, max_msg_interval);
00068 }
00069 
00070 void stomp_client::unsubscribe(const std::string& topic)
00071 {
00072    m_impl->unsubscribe(topic);
00073 }
00074 
00075 void stomp_client::send(const std::string& topic, const std::string& message)
00076 {
00077    m_impl->send(topic, message);
00078 }
00079 
00080 bool stomp_client::is_connected() const
00081 {
00082    return m_impl->is_connected();
00083 }
00084 
00085 bool stomp_client::is_online() const
00086 {
00087    return m_impl->is_online();
00088 }
00089 
00090 uint64_t stomp_client::get_num_processed() const
00091 {
00092    return m_impl->get_num_processed();
00093 }
00094 
00095 size_t stomp_client::get_num_pending() const
00096 {
00097    return m_impl->get_num_pending();
00098 }
00099 
00100 }}