clickermonkey-pubsubjs
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "clickermonkey-pubsubjs", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/ClickerMonkey/pubsub.js", | ||
@@ -5,0 +5,0 @@ "authors": [ |
{ | ||
"name": "clickermonkey-pubsubjs", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "pubsub with Socket.io", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -5,3 +5,3 @@ var app = require('express')(); | ||
var config = require('./config'); | ||
var config = require(process.argv[2] || './config'); | ||
var IdMap = require('./lib/IdMap'); | ||
@@ -18,9 +18,9 @@ var Channel = require('./lib/Channel'); | ||
var client = new Client( socket ); | ||
config.debug( 'Client Connected', socket.id ); | ||
/** | ||
* Handle when the client tries to subscribe to a channel. | ||
*/ | ||
socket.on('subscribe', function(msg) | ||
socket.on('subscribe', function(msg) | ||
{ | ||
@@ -48,10 +48,10 @@ var token = msg.token; | ||
}); | ||
/** | ||
* Handle when the client tries to unsubscribe from a channel. | ||
*/ | ||
socket.on('unsubscribe', function(msg) | ||
socket.on('unsubscribe', function(msg) | ||
{ | ||
var channelId = msg.id; | ||
ChannelFactory.get( channelId, false ).then( | ||
@@ -63,3 +63,3 @@ function onChannel(channel) | ||
client.leave( channel ); | ||
if (channel.size === 0) | ||
@@ -69,3 +69,3 @@ { | ||
} | ||
config.debug( 'Client', socket.id, 'unsubscribed from channel', channelId ); | ||
@@ -83,9 +83,9 @@ } | ||
); | ||
}); | ||
/** | ||
* Handle when the client tries to publish to a channel. | ||
*/ | ||
socket.on('publish', function(msg) | ||
socket.on('publish', function(msg) | ||
{ | ||
@@ -105,3 +105,3 @@ var data = msg.data; | ||
// if it's a valid publish | ||
channel.publish( client, | ||
channel.publish( client, | ||
{ | ||
@@ -111,3 +111,3 @@ id: channelId, | ||
}); | ||
config.debug( 'Client', socket.id, 'published to channel', channelId, ':', data ); | ||
@@ -132,10 +132,10 @@ }, | ||
}); | ||
/** | ||
* Handle when a client disconnects from the server. | ||
*/ | ||
socket.on('disconnect', function() | ||
socket.on('disconnect', function() | ||
{ | ||
client.destroy(); | ||
config.debug( 'Client Disconnected', socket.id ); | ||
@@ -146,2 +146,2 @@ }); | ||
http.listen( config.port ); | ||
http.listen( config.port ); |
@@ -7,5 +7,5 @@ # pubsub.js | ||
A `Channel` is a group of subscribers all listening for publish, join, & leave events. Channels are created when needed and are destroyed when there are no subscribers. | ||
A `Client` is a connection to the server from a web application that can be subscribed to any number of Channels. | ||
`pubsub.js` is built with safety in mind. All data sent to the server is validated before it creates channels, subscribes clients, or publishes to a channel. | ||
@@ -20,3 +20,3 @@ | ||
``` | ||
npm install | ||
npm install clickermonkey-pubsubjs | ||
``` | ||
@@ -27,3 +27,3 @@ | ||
``` | ||
node pubsub-server.js | ||
node node_modules/clickermonkey-pubsubjs/pubsub-server.js path/to/my/config.js | ||
``` | ||
@@ -59,3 +59,3 @@ | ||
port: 3000, | ||
/** | ||
@@ -65,3 +65,3 @@ * Whether or not to send a publish message back to the client who sent it. | ||
echoPublish: false, | ||
/** | ||
@@ -74,3 +74,3 @@ * If this server should notify clients when other clients have joined or left | ||
sendJoinLeaveEvents: true, | ||
/** | ||
@@ -80,3 +80,3 @@ * The maximum number of channels that can be created. | ||
maxChannels: -1, | ||
/** | ||
@@ -86,3 +86,3 @@ * The maximum number of clients that may connect. | ||
maxClients: -1, | ||
/** | ||
@@ -94,3 +94,3 @@ * If a client has sent an invalid channel ID, join token, or publish data | ||
ignoreInvalidClients: true, | ||
/** | ||
@@ -100,9 +100,9 @@ * The number of previous publishes to keep and send to a client when they join. | ||
sendLastPublishesOnJoin: 10, | ||
/** | ||
* Whether or not to send all of the join tokens of current clients to the | ||
* Whether or not to send all of the join tokens of current clients to the | ||
* new client when they first join the channel. | ||
*/ | ||
sendExistingClientsOnJoin: true, | ||
/** | ||
@@ -112,3 +112,3 @@ * Requires that a client must be subscribed to a channel before they can publish in it. | ||
requireSubscription: true, | ||
/** | ||
@@ -121,7 +121,7 @@ * Logs events (comment out console.log to disable) | ||
}, | ||
/**************************************************************************** | ||
* C H A N N E L I D V A L I D A T I O N | ||
****************************************************************************/ | ||
/** | ||
@@ -131,3 +131,3 @@ * The data types that are valid channel IDs. | ||
*/ | ||
validIds: | ||
validIds: | ||
{ | ||
@@ -140,3 +140,3 @@ 'number': true, | ||
}, | ||
/** | ||
@@ -152,3 +152,3 @@ * A function which does further validation on a channel ID. | ||
{ | ||
promise.$success(); | ||
promise.$success(); | ||
} | ||
@@ -162,7 +162,7 @@ else | ||
}, | ||
/**************************************************************************** | ||
* C L I E N T T O K E N V A L I D A T I O N | ||
****************************************************************************/ | ||
/** | ||
@@ -180,3 +180,3 @@ * The data types that are valid client tokens. | ||
}, | ||
/** | ||
@@ -192,3 +192,3 @@ * A function which does further validation on a client token. | ||
{ | ||
promise.$success(); | ||
promise.$success(); | ||
} | ||
@@ -202,7 +202,7 @@ else | ||
}, | ||
/**************************************************************************** | ||
* P U B L I S H V A L I D A T I O N | ||
****************************************************************************/ | ||
/** | ||
@@ -219,3 +219,3 @@ * The data types that are valid to publish to other clients. | ||
}, | ||
/** | ||
@@ -230,3 +230,3 @@ * A function which validates if a message by a client can be published on a channel. | ||
{ | ||
promise.$success(); | ||
promise.$success(); | ||
} | ||
@@ -240,4 +240,4 @@ else | ||
} | ||
} | ||
``` |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1201
51436
2