1) Yes. It is similar to pure websocket. But netty-socketio:
where
- 4 - message's packet type;
- 2 - event's inner type;
- eventName - a name of your event, it must be the same in your Java
@OnEvent
handler (see below).
You can organize your_data_objects as you wish, for example, write something like HTTP:
42["eventName", {headers map}, data(primitive, array or object)]
42["createUser", {"requestId": "UUID"}, {
"firstName": "John",
"lastName": "Dow"
}]
42["deleteUser", {}, 10]
42["getUsers", {}, [1,2,3,4,5]]
and etc.
(transport setting is required);
- require sending ping-pong packets
- 2 - PING,
- 3 - PONG
between your client and server or disabling it in a server's configuration (not recommended, it is useful for dead sessions).
supports easy to write authorization on handshake stage;
supports rooms. You can join/leave rooms (based on pub/sub in Hazelcast/Redisson) and send broadcast events only for these rooms;
supports acknowledge callbacks (can be disabled);
In conclusion, netty-socket-io is very useful, stable instrument and can be used in production.
2) Absolutely. You can use netty-socket-io on your Java backend side. And socket-io library on your client-side. Or even a pure websocket:
var ws = new Websocket("ws://localhost:9060/socket.io/?transport=websocket");
setInterval(function(){ sendHeartbeat(); }, 5000);
function sendHeartbeat() {
ws.send("2");
}
ws.onopen = function() {
ws.send('42["doSomething", {"header1": "value1"}, {"key1": "value1"}');
}
Java:
public class Controller {
@OnEvent("doSomething")
public void doSomething(SocketIOClient client, Headers headers, Something something) {
client.sendEvent("doSomethingSuccess", null, responseHeaders, responseObject);
}
}
And route to controller in configuration:
server.addListeners(new Controller());
3) Sadly, there is little information about netty-socket-io, you can just try it and create new issues when you in troubles;
4) You need to add netty-socket-io to your dependencies.
Hazelcast or Redisson if you are going to use them for storing sessions and subscriptions to rooms. Jackson for json serializing/deserializing. That's all.