Home

Awesome

vertx-tcp-eventbus-bridge

Build Status (5.x) Build Status (4.x)

This is a TCP eventbus bridge implementation.

The protocol

The protocol is quite simple:

Messages from the bridge -> client

Every JSON message will include a type key, with a string value. Each type is shown below, along with the companion keys for that type:

type: "pong"

pong requires no additional keys.

It is the response to the ping request from client to bridge.

type: "err"

type: "message"

For a regular message, the object will also contain:

When a message from the client requests a reply, and that reply fails, the object will instead contain:

Messages from the client -> bridge

The JSON object must contain a type key with a string value. Each type is shown below, along with the companion keys for that type:

type: "send", type: "publish"

When type is "send" if the message contains the key failureCode the original message will be failed, content is then:

type: "register", type: "unregister"

type: "ping"

ping requires no additional keys.

Example

An example nodejs client is provided as an example using the same API as SockJS bridge e.g.:

var EventBus = require('tcp-vertx-eventbus');

var eb = new EventBus('localhost', 7000);

eb.onopen = function () {
  // send a echo message
  eb.send('echo', {value: 'vert.x'}, function (err, res) {
    ...
  });
};