Git Product home page Git Product logo

stomptalk's Introduction

linux windows macos

stomptalk

stomp protocol parser http://stomp.github.io

This library does not perform any I/O operations for its own, is designed to be used in performance applications. It does not make any syscalls nor allocations, it does not buffer data, it can be interrupted at anytime. The parser can work with Stomp 1.0, 1.1, 1.2 and supports some of the rabbitmq headers.

Using

You must implement the hook_base interface.

struct hook_base
{
    virtual void on_frame(parser_hook&, const char *frame_start) noexcept = 0;
 
    virtual void on_method(parser_hook&, 
        std::uint64_t method_id, const char*, std::size_t) noexcept = 0;
 
    virtual void on_hdr_key(parser_hook&, 
        std::uint64_t hader_id, const char*, std::size_t) noexcept = 0;
 
    virtual void on_hdr_val(parser_hook&, const char*, std::size_t) noexcept = 0;
 
    virtual void on_body(parser_hook&, const void*, std::size_t) noexcept = 0;
 
    virtual void on_frame_end(parser_hook&, const char *frame_end) noexcept = 0;
};

If the request body is large, the on_body method will be called multiple times.

You can see example of integration at stompdemo or stompconn.

Pure C using

One stomptalk_parser object is used per TCP connection. Initialize the struct using stomptalk_parser_new() and set the callbacks. That might look something like this for a request parser:

#include "stomptalk/parser.h"

// create parser instance
stomptalk_parser *parser = stomptalk_parser_new();

stomptalk_parser_hook hook = {
    .on_frame = at_frame,
    .on_method = at_method,
    .on_hdr_key = at_hdr_key,
    .on_hdr_val = at_hdr_val,
    .on_body = at_body,
    .on_frame_end = at_frame_end
};

// setup user callabacks
stomptalk_set_hook(parser, &hook, my_connection_ptr);

// ...

// parse some data from socket
size_t rc = stomptalk_parser_execute(parser, data, data_size);

// ...

// cleanup
stomptalk_parser_free(parser);

// convert text with unsigned number
// it return negative value if error
int64_t rc = stomptalk_antoull(at, length);

See the example at purestomp.

Building

CMake (Windows)

Install CMake: https://www.cmake.org

$ md build && cd build
$ cmake -G "Visual Studio 16 2019" -A x64 ..
$ cmake --build . --config Release
CMake (Unix)
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make

stomptalk's People

Contributors

ikonopistsev avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

prinze77

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.