New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the use of a custom parser #2829

Merged
merged 1 commit into from Jan 24, 2017

Conversation

Projects
None yet
1 participant
@darrachequesne
Copy link
Member

darrachequesne commented Jan 19, 2017

The kind of change this PR does introduce

  • a new feature

New behaviour

This would enable the use of some custom parsers, like the following based on msgpack:

const msgpack = require('notepack.io');
const Emitter = require('component-emitter');

class Encoder {
  encode(obj, callback){
    var encoded = msgpack.encode(obj);
    callback([encoded]);
  }
}

class Decoder extends Emitter {
  add(obj){
    var decoded = msgpack.decode(obj);
    this.emit('decoded', decoded);
  }
  destroy(){}
}

exports.Encoder = Encoder;
exports.Decoder = Decoder;

And then:

const server = require('http').createServer();
const myCustomParser = require('./my-custom-parser');
const io = require('socket.io')(server, {
  parser: myCustomParser
});

That would also provide a workaround for socketio/socket.io-parser#61.

Related: #1652 #1946

Note: that would need to update socket.io-client and socket.io-adapter too.

@darrachequesne darrachequesne merged commit 3b92cc2 into socketio:master Jan 24, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@darrachequesne darrachequesne deleted the darrachequesne:feature/custom-parser branch Jan 24, 2017

darrachequesne pushed a commit to darrachequesne/socket.io-adapter that referenced this pull request Feb 16, 2017

Damien Arrachequesne
Remove the socket.io-parser dependency
That will allow to use a custom parser (see socketio/socket.io#2829).

darrachequesne added a commit to socketio/socket.io-adapter that referenced this pull request Feb 16, 2017

darrachequesne pushed a commit to darrachequesne/socket.io-client that referenced this pull request Feb 17, 2017

darrachequesne added a commit to darrachequesne/socket.io-client that referenced this pull request Feb 20, 2017

darrachequesne added a commit to socketio/socket.io-client that referenced this pull request Feb 20, 2017

@darrachequesne darrachequesne added this to the 2.0.0 milestone May 13, 2017

@darrachequesne darrachequesne referenced this pull request Jun 3, 2017

Closed

Add the hasBinary flag #2838

3 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment