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

vubsub

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vubsub - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

29

lib/channel.js

@@ -73,2 +73,8 @@ var util = require('util')

}
Channel.prototype._close = function() {
if (this.cursor) {
this.cursor.close();
this.cursor = null;
}
}

@@ -78,13 +84,20 @@ Channel.prototype.send = function(type, data) {

return self.collection.then(function(collection) {
var data = {
ts: new Date(),
channel: self.name,
from: self.client.id,
type: type,
data: data
};
return q.ninvoke(collection, 'insert', data);
return Channel.send(collection, self.client.id, self.name, type, data);
});
}
Channel.prototype.leave = function() {
self.client.leave(this);
}
Channel.send = function(collection, client, channel, type, data) {
var data = {
ts: new Date(),
channel: channel,
from: client,
type: type,
data: data
};
return q.ninvoke(collection, 'insert', data);
}
module.exports = Channel;

@@ -14,3 +14,3 @@ var q = require('q')

}
Client.prototype.channel = function(name, lastMessage) {
Client.prototype.channel = Client.prototype.join = function(name, lastMessage) {
if (this.channels[name]) {

@@ -21,5 +21,17 @@ return this.channels[name];

this.channels[name] = channel;
this.db.collection('clients').update({ _id: this.id }, { $set: { "channels." + channel.name: new Date() }});
return channel;
}
}
Client.prototype.leave = function(channel) {
this.db.collection('clients').update({ _id: this.id }, { $unset: { "channels." + channel.name: true }});
channel._close();
delete this.channels[name];
}
Client.prototype.send = function(channel, type, data) {
return exports.send(this.db, this.namespace, this.id, channel, type, data);
}
Client.prototype.sendns = function(namespace, channel, type, data) {
return exports.send(this.db, namespace, this.id, channel, type, data);
}

@@ -54,1 +66,5 @@ var clients = {};

}
exports.send = function(db, namespace, client, channel, type, data) {
return Channel.send(db.collection('ns_' + namespace), client, channel, type, data);
}
{
"name": "vubsub",
"version": "1.0.0",
"version": "1.0.1",
"description": "Pub/Sub for Node.js and MongoDB",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/vivocha/vubsub",

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