Build Status

Introduction

StompOut is an implementation of the Simple Text Orientated Messaging Protocol (STOMP). Both a client and server interface to the protocol are provided. They are implemented independent of the underlying network protocol over which they are applied. In that sense they run outboard of the underlying connection, hence “Out” in the name. The Client and Server classes provide a function for receiving blocks of STOMP encoded data from the connection and they expect the subclass to implement a function for sending data that has been STOMP encoded over the connection.

The Client and Server classes support version 1.0, 1.1, and 1.2 of STOMP. The built-in version negotiation in the protocol determines which is actually applied for a given connection.

Interface

Client

There are two parts to the interface: the functions the StompOut::Client class exposes and the functions the Client subclass must implement.

The Client exposes the following functions:

The Client subclass must implement the following functions:

Server

There are two parts to the interface: the functions the StompOut::Server class exposes and the functions the Server subclass must implement.

The Server exposes the following functions:

The Server subsclass must implement the following functions:

The above functions should raise StompOut::ApplicationError for requests that violate any application specific constraints.

Example

The gem contains client and server examples of how it can be applied in a WebSocket environment. The server example can be run in the examples directory using thin:

thin -R config.ru start

The client example is a script that can executed against the server, e.g., to produce messages:

./websocket_client.rb -u ws://0.0.0.0:3000 -d /queue -m "hi"
./websocket_client.rb -u ws://0.0.0.0:3000 -d /queue -m "bye"

and to consume messages:

./websocket_client.rb -u ws://0.0.0.0:3000 -d /queue -a client -r

Dependencies

The eventmachine gem is used only if the STOMP heartbeat feature is used. The the json gem is used by the Client only if a content-type is “application/json” and the :auto_json option is enabled. The examples make use of the faye-websocket, eventmachine, trollop, and json gems.

License

This software is released under the MIT License. Please see LICENSE for further details.

Copyright © 2015 RightScale