Skip to content
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

Custom parser support #234

Open
Totodore opened this issue Jan 17, 2024 · 2 comments · May be fixed by #231
Open

Custom parser support #234

Totodore opened this issue Jan 17, 2024 · 2 comments · May be fixed by #231
Labels
enhancement New feature or request help wanted Extra attention is needed socketio-v4 It is only about the version 4 of the socket.io protocol socketio-v5 It is only about the version 5 of the socket.io protocol

Comments

@Totodore
Copy link
Owner

Is your feature request related to a problem? Please describe.
It is currently impossible to use external parser like msgpack. Moreover, using msgpack as a parser is a way do solve issue #232 because binary packets with msgpack are sent in one ws frame.

Describe the solution you'd like

  • Add a boxed trait Parser that is held by the SocketIoConfig and set with the with_parser fn
  • The boxed trait parser is then held by the Client to encode/decode packets.
@Totodore Totodore added enhancement New feature or request socketio-v4 It is only about the version 4 of the socket.io protocol socketio-v5 It is only about the version 5 of the socket.io protocol labels Jan 17, 2024
@Totodore Totodore linked a pull request Jan 17, 2024 that will close this issue
4 tasks
@Totodore Totodore added the help wanted Extra attention is needed label Jan 17, 2024
@Totodore
Copy link
Owner Author

After considering all the possibilities to solve this issue I came to think that we should simply implement the msgpack parser as an enum based solution.

enum Parser {
    Common(CommongParser),
   #[cfg(feature = "msgpack-parser")]
    MsgPack(MsgPackParser),
}

/// Public API implemented for Parser and delegating the actions either to the 
/// `CommongParser` or the `MsgPackParser` based on a flag in the configuration.

My other points for this solution are:

@FabianHummel what are your thoughts on this? As you already started to implement something.

@FabianHummel
Copy link

Using enums sounds good to me, especially because they are on the stack which is far bettern than trait objects. When people want to implement other parsers they could then simply open a PR and try to get them officially added to the parser list.

Honestly, I haven't worked on this PR for a while now, but I'll consider taking a look and try to come up with something that can be worked with. Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed socketio-v4 It is only about the version 4 of the socket.io protocol socketio-v5 It is only about the version 5 of the socket.io protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants