Skip to content

Commit

Permalink
Add option to set the maxListeners (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Faianca authored and daffl committed Aug 21, 2018
1 parent 22be348 commit 58f490b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/socketio/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ export default function (options, config) {
});
}

if (typeof config === 'function') {
debug('Calling SocketIO configuration function');
config.call(this, io);
}

this._socketInfo = {
method: 'emit',
connection () {
Expand All @@ -52,6 +47,11 @@ export default function (options, config) {
// So we set it to a higher number. 64 should be enough for everyone.
this._socketInfo.connection().setMaxListeners(64);

if (typeof config === 'function') {
debug('Calling SocketIO configuration function');
config.call(this, io);
}

return this._super.apply(this, arguments);
}
}, app);
Expand Down
12 changes: 12 additions & 0 deletions packages/socketio/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ describe('feathers-socketio', () => {
let srv = app.listen(8887).on('listening', () => srv.close(done));
});

it('can set MaxListeners', done => {
let app = feathers()
.configure(socketio(function (io) {
io.sockets.setMaxListeners(100);
}));

let srv = app.listen(8987).on('listening', () => {
assert.equal(app.io.sockets.getMaxListeners(), 100);
srv.close(done);
});
});

it('can set options (#12)', done => {
let app = feathers()
.configure(socketio({
Expand Down

0 comments on commit 58f490b

Please sign in to comment.