I am using the following project to build a socket.io server: https://github.com/mrniko/netty-socketio
My server:
public class ServerTest {
public static void main(String... args) {
Configuration config = new Configuration();
config.setPort(8080);
config.setAuthorizationListener(new AuthorizationListener() {
public boolean isAuthorized(HandshakeData handshakeData) {
System.out.println("yes!" + handshakeData.getAddress());
return true;
}
});
final SocketIOServer server = new SocketIOServer(config);
server.addEventListener("message", String.class, new DataListener<String>() {
public void onData(SocketIOClient socketIOClient, String s, AckRequest ackRequest) throws Exception {
System.out.println("hey");
}
});
server.start();
}
}
I accept all connections, I have tested the connection like this with socket.io javascript client:
var ws = io.connect('localhost:8080');
ws.on('connect', function() {
ws.emit('message', "I am a message!");
});
Now, I get the print "hey", but what if I send a data object like this:
ws.emit('message', {data: "I am a message!"});
How can I decode this message? Is there a way to debug what object type is being sent to the server?