Comparing version 0.7.1 to 0.7.2
@@ -14,3 +14,3 @@ /* | ||
"*::customPing" : function(msg) { | ||
console.log('custom ping') | ||
console.log('custom ping'); | ||
msg = 'foo ' + msg; | ||
@@ -17,0 +17,0 @@ pingPongModule.ping(msg); |
@@ -62,3 +62,11 @@ /* | ||
// | ||
// Load the nconf store into memory | ||
// | ||
var config = this.config.store.store; | ||
// | ||
// Iterate over nconf store and copy key values, | ||
// to Hook | ||
// | ||
Object.keys(config).forEach(function (o) { | ||
@@ -68,2 +76,17 @@ self[o] = config[o]; | ||
// | ||
// Iterate over argv and copy key values, | ||
// to Hook ( overwriting duplicate keys from config ) | ||
// | ||
Object.keys(argv).forEach(function (o) { | ||
var reserved = ["hook-port", "hook-host"]; | ||
if(reserved.indexOf(o) === -1){ | ||
self[o] = argv[o]; | ||
} | ||
}); | ||
// | ||
// Iterate over options and copy key values, | ||
// to Hook ( overwriting duplicate keys from config ) | ||
// | ||
Object.keys(options).forEach(function (o) { | ||
@@ -304,3 +327,3 @@ self[o] = options[o]; | ||
event = !remote ? [self.name, this.event].join(DELIMITER) : this.event; | ||
// | ||
@@ -312,6 +335,35 @@ // Only broadcast if the client has a message function, it is not a reserved | ||
if (client.message && reserved.indexOf(parts[0]) === -1 && parts[0] !== client.name) { | ||
this.transports.forEach(function(transport) { | ||
_transports[transport.type].message(transport.options, event, data); | ||
// | ||
// Remark: The current approach for minimizing excess messaging is, | ||
// to send a message to every client first, to determine if the actual, | ||
// message should get sent. | ||
// | ||
// | ||
// TODO: This is a good start, but ultimately we need to reduce the, | ||
// total amount of network hops ( period ). We need to store the available event | ||
// table in memory, and then intelligently know when to update it. | ||
// | ||
// In most cases, we can just store this on Hook connection, and never update it | ||
// | ||
// | ||
// Remark: Before sending any message, request client for registered events | ||
// and send message with data only if the client is interrested in this event | ||
// | ||
client.hasEvent(parts, remote, function(err, send) { | ||
if (!send) { | ||
// | ||
// Remark: We may want to do something with this event. | ||
// | ||
// self.emit('hook::noevent', event); | ||
return; | ||
} | ||
self.transports.forEach(function(transport) { | ||
_transports[transport.type].message(transport.options, event, data); | ||
}); | ||
client.message(event, data); | ||
}); | ||
client.message(event, data); | ||
} | ||
@@ -373,2 +425,29 @@ }); | ||
self.emit(event, data, true); | ||
}, | ||
hasEvent: function(parts, remote, callback) { | ||
// begin the walk from * namespace | ||
var map = self.getEvents(), | ||
root = remote ? map : map['*']; | ||
// begin the walk from * namespace and handle remote case, | ||
// where we need to search the first part as if | ||
// it was a `*` | ||
parts[0] = remote ? '*' : parts[0]; | ||
// walk the event map to find any handler | ||
parts.forEach(function(part, i) { | ||
// If the event emitted is '*' at this part | ||
// or there is a concrete match | ||
var wildcard = root && root['*']; | ||
root = root ? (root[part] || null) : root; | ||
// at this point, if the root is set to null, assign wildcard value if there is any | ||
root = root ? root : wildcard; | ||
}); | ||
// if root is falsy (null), then assume there's no listener for this specific | ||
// client, prevent message sending | ||
callback(null, !!root); | ||
} | ||
@@ -417,3 +496,2 @@ }); | ||
names; | ||
function onError (err) { | ||
@@ -595,5 +673,3 @@ self.emit('error::spawn', err); | ||
if (this.debug) { | ||
var truncatedData = data.length > 50 | ||
? data.substr(0, 50) + ' ... ' | ||
: truncatedData = data; | ||
var truncatedData = data; | ||
@@ -643,3 +719,3 @@ console.log(pad(hook, 30).magenta, pad(event, 25).green, truncatedData.grey); | ||
// | ||
// TODO: Refactor 'reserved_cli' and module scopeds 'reserved' into Protoype variable with nested namespaces | ||
// TODO: Refactor 'reserved_cli' and module scoped 'reserved' into Protoype variable with nested namespaces | ||
// | ||
@@ -646,0 +722,0 @@ var reserved_cli = ['port', 'host', 'name', 'type']; |
{ | ||
"author": "Marak Squires <marak.squires@gmail.com>", | ||
"name": "hook.io", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -18,2 +18,4 @@ __ __ ______ ______ __ ___ __ ______ | ||
### 20 Video lessons available at: [http://youtube.com/maraksquires](http://youtube.com/maraksquires) and [http://github.com/hookio/tutorials](http://github.com/hookio/tutorials) | ||
# Features : | ||
@@ -77,3 +79,3 @@ | ||
## Contributors (through code and advice) | ||
Substack, h1jinx, AvianFlu, Chapel, Dominic Tarr, Tim Smart, tmpvar, kadir pekel, perezd | ||
Substack, h1jinx, AvianFlu, Chapel, Dominic Tarr, Tim Smart, tmpvar, kadir pekel, perezd, mklabs | ||
@@ -80,0 +82,0 @@ [0]: http://groups.google.com/group/hookio |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
48463
31
1371
86
2
3