0.0.3 • Published 6 years ago

stomp-raw v0.0.3

Weekly downloads
1
License
GPL-3.0
Repository
-
Last release
6 years ago

stomp-raw

stomp-raw is a low level stomp library, working at the TCP text stream level, that allows writing valid STOMP protocol messages but also allows writing invalid STOMP messages.

This tool is used for negative testing of xtomp it should be useful for testing any STOMP broker.

The following example shows testing sending STOMP heart-beats (single '\n').

const StompRaw = require('stomp-raw').StompRaw;

const stompRaw = new StompRaw();

stompRaw.on("connect", function() {
    stompRaw.write("CONNECT\n\n\0");
});

stompRaw.on("frame", function(frame) {

    while (frame.charAt(0) === '\n' || frame.charAt(0) === '\r') {
        console.log("leading whitespace detected");
        frame = frame.substring(1);
    }

    if ( frame.startsWith("CONNECTED") ) {
        setInterval(() => {

            stompRaw.write("\n");

        }, 50);

        setTimeout(() => {
            stompRaw.write("SEND\ndestination:memtop-a\n\nmessage data\0");
        }, 100);

        setTimeout(() => {
            stompRaw.end();
            process.exit(0);
        }, 500);

    }
    else {
        console.log("error");
        stompRaw.end();
    }
});

stompRaw.connect();

xtomp on github