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

radar_client

Package Overview
Dependencies
Maintainers
5
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

radar_client - npm Package Compare versions

Comparing version 0.2.18 to 0.3.1

tests/backoff.test.js

32

dist/radar_client.js

@@ -34,2 +34,3 @@ (function(){function require(e,t){for(var n=[],r=e.split("/"),i,s,o=0;s=r[o++];)".."==s?n.pop():"."!=s&&n.push(s);n=n.join("/"),o=require,s=o.m[t||0],i=s[n+".js"]||s[n+"/index.js"]||s[n];if(s=i.c)i=o.m[t=s][e=i.m];return i.exports||i(i,i.exports={},function(n){return o("."!=n.charAt(0)?n:e+"/../"+n,t)}),i.exports};

instance._log = require('minilog');
instance._logger = instance._log('radar_client');
instance.Backoff = Backoff;

@@ -84,8 +85,13 @@

Client.prototype.logger = function() {
return this._logger || log;
};
// alloc() and dealloc() rather than connect() and disconnect() - see readme.md
Client.prototype.alloc = function(name, callback) {
log.info({ op: 'alloc', name: name });
this.logger().info({ op: 'alloc', name: name });
var self = this;
this._users[name] = true;
callback && this.once('ready', function() {
this.logger().info('ready', name);
if(self._users.hasOwnProperty(name)) {

@@ -106,5 +112,8 @@ callback();

Client.prototype.dealloc = function(name) {
log.info({ op: 'dealloc', name: name });
this.logger().info({ op: 'dealloc', name: name });
delete this._users[name];
var stillAllocated = false, key;
for (key in this._users) {

@@ -117,2 +126,3 @@ if (this._users.hasOwnProperty(key)) {

if (!stillAllocated) {
this.logger().info("closing the connection");
this.manager.close();

@@ -224,2 +234,4 @@ }

Client.prototype._write = function(message, callback) {
var client = this;
if(callback) {

@@ -229,2 +241,3 @@ message.ack = this._ackCounter++;

this.when('ack', function(m) {
client.logger().debug('ack', m);
if(!m || !m.value || m.value != message.ack) {

@@ -280,3 +293,3 @@ return false;

socket.once('open', function() {
log.info("socket open", socket.id);
client.logger().debug("socket open", socket.id);
manager.established();

@@ -286,3 +299,3 @@ });

socket.once('close', function(reason, description) {
log.info('socket closed', socket.id, reason, description);
client.logger().debug('socket closed', socket.id, reason, description);
socket.removeAllListeners('message');

@@ -359,3 +372,3 @@ client._socket = null;

log.info('restore-subscriptions');
this.logger().debug('restore-subscriptions');

@@ -383,2 +396,3 @@ for (to in this._subscriptions) {

var memorized = this._memorize(message);
this.emit('message:out', message);

@@ -398,4 +412,3 @@ if (this._socket && this.manager.is('activated')) {

var message = JSON.parse(msg);
message.direction = 'in';
log.info(message);
this.emit('message:in', message);
switch (message.op) {

@@ -506,2 +519,4 @@ case 'err':

var time = backoff.get();
log.info("reconnecting in " + time + "msec");
this._timer = setTimeout(function() {

@@ -512,5 +527,6 @@ delete machine._timer;

}
}, backoff.get());
}, time);
if (backoff.isUnavailable()) {
log.info("unavailable");
this.emit('unavailable');

@@ -517,0 +533,0 @@ }

@@ -6,2 +6,3 @@ var Client = require('./radar_client'),

instance._log = require('minilog');
instance._logger = instance._log('radar_client');
instance.Backoff = Backoff;

@@ -8,0 +9,0 @@

@@ -44,8 +44,13 @@ var log = require('minilog')('radar_client'),

Client.prototype.logger = function() {
return this._logger || log;
};
// alloc() and dealloc() rather than connect() and disconnect() - see readme.md
Client.prototype.alloc = function(name, callback) {
log.info({ op: 'alloc', name: name });
this.logger().info({ op: 'alloc', name: name });
var self = this;
this._users[name] = true;
callback && this.once('ready', function() {
this.logger().info('ready', name);
if(self._users.hasOwnProperty(name)) {

@@ -66,5 +71,8 @@ callback();

Client.prototype.dealloc = function(name) {
log.info({ op: 'dealloc', name: name });
this.logger().info({ op: 'dealloc', name: name });
delete this._users[name];
var stillAllocated = false, key;
for (key in this._users) {

@@ -77,2 +85,3 @@ if (this._users.hasOwnProperty(key)) {

if (!stillAllocated) {
this.logger().info("closing the connection");
this.manager.close();

@@ -184,2 +193,4 @@ }

Client.prototype._write = function(message, callback) {
var client = this;
if(callback) {

@@ -189,2 +200,3 @@ message.ack = this._ackCounter++;

this.when('ack', function(m) {
client.logger().debug('ack', m);
if(!m || !m.value || m.value != message.ack) {

@@ -240,3 +252,3 @@ return false;

socket.once('open', function() {
log.info("socket open", socket.id);
client.logger().debug("socket open", socket.id);
manager.established();

@@ -246,3 +258,3 @@ });

socket.once('close', function(reason, description) {
log.info('socket closed', socket.id, reason, description);
client.logger().debug('socket closed', socket.id, reason, description);
socket.removeAllListeners('message');

@@ -319,3 +331,3 @@ client._socket = null;

log.info('restore-subscriptions');
this.logger().debug('restore-subscriptions');

@@ -343,2 +355,3 @@ for (to in this._subscriptions) {

var memorized = this._memorize(message);
this.emit('message:out', message);

@@ -358,4 +371,3 @@ if (this._socket && this.manager.is('activated')) {

var message = JSON.parse(msg);
message.direction = 'in';
log.info(message);
this.emit('message:in', message);
switch (message.op) {

@@ -362,0 +374,0 @@ case 'err':

@@ -65,2 +65,4 @@ var log = require('minilog')('radar_state'),

var time = backoff.get();
log.info("reconnecting in " + time + "msec");
this._timer = setTimeout(function() {

@@ -71,5 +73,6 @@ delete machine._timer;

}
}, backoff.get());
}, time);
if (backoff.isUnavailable()) {
log.info("unavailable");
this.emit('unavailable');

@@ -76,0 +79,0 @@ }

{
"name": "radar_client",
"description": "Realtime apps with a high level API based on engine.io",
"version": "0.2.18",
"version": "0.3.1",
"author": "Mikito Takada <mikito.takada@gmail.com>",
"contributors": [
{
"name": "Sam Shull",
"url": "http://github.com/samshull"
},
{
"name": "Vanchi Koduvayur",
"url": "https://github.com/vanchi-zendesk"
},
{
"name": "Nicolas Herment",
"url": "https://github.com/nherment"
}
],
"main": "lib/index.js",

@@ -10,7 +24,7 @@ "keywords": ["realtime", "socket.io", "engine.io", "comet", "ajax"],

"type": "git",
"url": "https://github.com/zendesk/engine.io.git"
"url": "https://github.com/zendesk/radar_client.git"
},
"dependencies": {
"microee": "0.0.2",
"minilog": "0.0.4",
"minilog": "2.0.5",
"engine.io-client": "0.2.x",

@@ -24,5 +38,13 @@ "sfsm": "0.0.4"

"scripts": {
"test": "npm run build && make test",
"build": "make build"
"check-modules": "if [ -z \"$SKIP_PACAKGE_CHECK\" ] && [ ./package.json -nt ./node_modules ]; then echo 'Your node_modules are out of date. Please run \"npm update\".' && exit 1; else rm -rf ./node_modules/sfsm/demo; fi",
"pretest": "npm run build",
"test": "ls ./tests/*.test.js | xargs -n 1 -t -I {} sh -c 'TEST=\"{}\" npm run test-one'",
"pretest-one": "[ -z \"$radar_log\" ] && export radar_log=-*",
"test-one": "./node_modules/.bin/mocha --ui exports --reporter spec --slow 2000ms --bail \"$TEST\"",
"prebuild": "npm run check-modules",
"build": "./node_modules/gluejs/bin/gluejs --include ./lib --npm microee,sfsm --replace engine.io-client=window.eio,minilog=window.Minilog --global RadarClient --main lib/index.js --out dist/radar_client.js"
}
}
# Radar Client
High level API and backend for writing web apps that use push messaging
High level API and backend for writing web apps that use push messaging.
The radar server code is here: https://github.com/zendesk/radar
[![Build Status](https://secure.travis-ci.org/zendesk/radar_client.png?branch=master)](https://travis-ci.org/zendesk/radar_client)

@@ -6,0 +8,0 @@

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