Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marionette-client

Package Overview
Dependencies
Maintainers
2
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marionette-client - npm Package Compare versions

Comparing version 0.5.4 to 0.5.5

63

lib/marionette/drivers/tcp.js
var Abstract, CommandStream;
var net = require('net');
var debug = require('debug')('marionette:tcp');

@@ -6,6 +8,51 @@ Abstract = require('./abstract');

var MAX_TRIES = 20;
var WAIT_BETWEEN_TRIES_MS = 250;
/** TCP **/
Tcp.Socket = require('net').Socket;
Tcp.Socket = net.Socket;
/**
* Tries to connect to a given socket location.
* Will retry on failure.
*
* waitForSocket(2828, 'localhost', function(err, socket) {
* });
*
* Note- there is a forth argument used to recursion that should
* never be used publicly.
*
* @param {Number} port to connect to.
* @param {String} host like localhost.
* @param {Function} callback [err, socket].
*/
function waitForSocket(port, host, callback, _tries) {
debug('attempt to open socket', port, host);
_tries = _tries || 0;
if (_tries >= MAX_TRIES)
return callback(err);
function handleError() {
debug('socket is not ready trying');
// retry connection
setTimeout(
waitForSocket,
WAIT_BETWEEN_TRIES_MS,
port,
host,
callback,
++_tries
);
}
var socket = new Tcp.Socket();
socket.connect(port, host, function(one, two) {
debug('connected', port, host);
socket.removeListener('error', handleError);
callback(null, socket);
});
socket.once('error', handleError);
}
/**
* NodeJS only tcp socket driver for marionette.

@@ -23,8 +70,8 @@ * See {{#crossLink "Marionette.Drivers.MozTcp"}}{{/crossLink}}

function Tcp(options) {
if (typeof(options)) {
if (!options) {
options = {};
}
Abstract.call(this, options);
this.connectionId = 0;

@@ -61,6 +108,8 @@ /**

this.socket = new Tcp.Socket();
this.socket.connect(this.port, this.host);
client = this.client = new CommandStream(this.socket);
this.client.on('command', this._onClientCommand.bind(this));
waitForSocket(this.port, this.host, function(err, socket) {
debug('got socket starting command stream');
this.socket = socket;
client = this.client = new CommandStream(this.socket);
this.client.on('command', this._onClientCommand.bind(this));
}.bind(this));
};

@@ -67,0 +116,0 @@

@@ -200,2 +200,3 @@ (function(module, ns) {

Responder.prototype.on = Responder.prototype.addEventListener;
Responder.prototype.removeListener = Responder.prototype.removeEventListener;

@@ -202,0 +203,0 @@ module.exports = Responder;

2

package.json
{
"name": "marionette-client",
"version": "0.5.4",
"version": "0.5.5",
"main": "lib/marionette/index",

@@ -5,0 +5,0 @@ "description": "Marionette Javascript Client",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc