engine.io-server-java
engine.io-server-java copied to clipboard
Make it easy to use with Jackson
Right now the library has a hard dependency on org.json. This is problematic for two reasons:
- org.json has a non standard license which makes people wary
- You many times want your message to be deserialized to a bean type. Creating a
JSONObjectout of the received JSON is purely overhead.
I haven't looked very deeply into this yet but this code I have in my project does not seem very optimal:
socket.on("message", ee -> {
JSONObject json = (JSONObject) ee[0];
AbstractServerMessage message = objectMapper.readValue(json.toString(), AbstractServerMessage.class);
I'm considering how to enable the user to hook their own json library. I'll update you once I've figured it out.
I've been working on this for a while now (it was always in the roadmap), and I'm coming up short on viable solutions due to the way the protocol works. It should be possible to return string (allowing the user to use whatever parser they want) instead of JSONObject or JSONArray. But one immediate downside is it'll become difficult to support byte[] fields due to the way they're handled by the protocol.
I'd appreciate more insight into this and like to hear different approaches that could be used.
Currently, all byte[] fields are extracted out and transferred separately. The client is responsible for patching those in after receiving the payload.