I'm currently playing around with a Java implementation of Socket.io, available here: netty-socketio
I've got the server up and running, and its receiving/sending messages nicely between client and server, but I need to have events trigger on certain messages being received, and that's where I'm confused.
Here's my code:
server.addEventListener("message", clientData.class, new DataListener<clientData>() {
@Override
public void onData(SocketIOClient client, clientData data, AckRequest ackRequest) throws Exception {
System.out.println("Message from client: " + data.getMessage());
}
});
public class ClientData{
String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
Essentially what I'd like to happen is when a particular message is received from a client, I need a function within another class to run. I've spent the last two hours reading about Observable, Observer, Interfaces and event handlers, but I'm really not sure how to set this up.
The library also makes mention of this DataListener, but I've no idea what that is, as there's little documentation in the library.
Any input or advice on this would be greatly appreciated.