I want to callback the server to ack that my client has received a call. In the opposite direction, this is heavily documented and working fine, but how can I ack from the client?
NB: I am using socket-io-java-client https://github.com/socketio/socket.io-client-java on Android, not JavaScript, but it shouldn't matter. Well, maybe it does.
socket.on("onMessage", new Emitter.Listener() {
@Override public void call(Object... args) {
// I have the args here and the last argument is a callback,
// but what do I need to do to callback the server using that arg?
}
})
In Swift it looks like this, but I can't figure out how to do this in Java with the above mentioned library.
socket.on("onMessage") { data, ack in
ack?()
}
Has anybody done this or knows how to achieve that?
I overlooked this. There is an example posted here:
https://github.com/socketio/socket.io-client-java
// ack from client to server
socket.on("foo", new Emitter.Listener() {
@Override
public void call(Object... args) {
Ack ack = (Ack) args[args.length - 1];
ack.call();
}
});
[Credits go to Alex who just skyped me the URL.]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With