Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A C++ STOMP client using the Boost ASIO library
C++
tree: c473992911

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
BoostStomp.cpp
BoostStomp.hpp
Main.cpp
Makefile
README
StompFrame.cpp
StompFrame.hpp
helpers.cpp
helpers.h

README

/************
BoostStomp
/************
A simple C++ STOMP client ( http://stomp.github.com ), 
written with standard STL and boost ( http://www.boost.org )

For Debian, the packages you'll be needing in order to compile are:

libboost1.xx-dev (Boost base files)
libboost_system1.xx (1.xx==depending on your Debian version) 
libboost_system1.xx-dev
libboost_thread1.xx (thread support)
libboost_thread1.xx-dev

There is an example of usage, in Main.cpp. It gets built by default, 
along with the shared & static versions of the booststomp library.
Usage is simple: construct a BoostStomp object passing it the hostname 
and port of the STOMP server:

    string  stomp_host = "localhost";
    int     stomp_port = 61613;
    stomp_client = new BoostStomp(stomp_host, stomp_port);

..then, start it to initiate the TCP & STOMP connection:

    stomp_client->start();
    
..then, subscribe to a channel, and pass in a callback for the handling of any messages of interest:

    string  notifications_topic = "/queue/zwave/monitor";
    stomp_client->subscribe(*notifications_topic, (STOMP::pfnOnStompMessage_t) &subscription_callback);

..then you can construct STOMP frames, adding in any headers you like, and add them to the send queue:
 
        STOMP::hdrmap headers;
        headers["header1"] = string("value1");
        headers["header2:withcolon"] = string("value2");
        headers["header3"] = string("value3");
        string body = string("this is the main message body");

        // add an outgoing message to the queue
        stomp_client->send(*notifications_topic, headers, body);
	
You must remember at all times that since we are using an asynchronous i/o
model,  any messages sent via BoostStomp are _not_ guaranteed to succeed.

Future versions of the library will support overloaded versions with completion
callbacks (following th boost::asio model).

April 2012,
Elias Karakoulakis
Something went wrong with that request. Please try again.