Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[fix] Events should be immutable across reactors.
  • Loading branch information
indexzero committed Mar 22, 2013
1 parent 36e117a commit cd48890
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/godot/common/index.js
Expand Up @@ -11,9 +11,19 @@
//
exports.clone = function (data) {
return Object.keys(data).reduce(function (obj, key) {
obj[key] = key === 'tags'
? data[key].slice()
: data[key];
if (key === 'tags') {
obj[key] = data[key].slice()
}
else if (key === 'meta') {
//
// TODO: Fast close meta
//
obj[key] = data[key];
}
else {
obj[key] = data[key];
}

return obj;
}, {});
};
Expand Down
3 changes: 2 additions & 1 deletion lib/godot/net/server.js
Expand Up @@ -282,7 +282,8 @@ Server.prototype._onTcpSocket = function (socket) {

parser.on('data', function (event) {
reactors.forEach(function (reactor) {
reactor.source.write(event);
var copy = common.clone(event);
reactor.source.write(copy);
});
});

Expand Down

0 comments on commit cd48890

Please sign in to comment.