Primus-Tcp
Primus Raw TCP Transformer.
Connect Node.js to Vanilla TCP Servers via Primus.
Getting Started
Install the transformer with this command:
npm install primus-tcp --save
Add the transformer to the Primus constructor and subscribe to the events.
var primus = require('primus');
var transformer = require('primus-tcp/transformer/tcp');
var parser = require('primus-tcp/parser/pipe');
var PrimusSocket = primus.createSocket({
transformer: transformer,
parser: parser
});
var url = "...";
var options = { };
var connection = new PrimusSocket(url, options);
connection.on("open", function(){ });
connection.on("end", function(){ });
connection.on("reconnect", function(){ });
connection.on("error", function(){ });
connection.on("data", function(data){ });
Now we are able to connect to a vanilla tcp server (Java?) and still keep all the neat abstractions (reconnect, heartbeat, etc) that Primus provides.