Does the IOAcknowledge method NOT work for SocketIO on Android?

I use socketio.jar to establish a connection between Client and Server .

those. from my Android device (Client) to the Node server.

Since I can successfully connect, send and receive messages to this server.

The problem is that I do NOT receive a confirmation from the socket after sending the message to the server. As a parameter there is a callBack Interface IOAcknowledge interface that never works / calls for me.

socket.emit( "sendMessage", new IOAcknowledge() { @Override public void ack(Object... arg0) { System.out.println("sendMessage IOAcknowledge" + arg0.toString()); } }, "Hi!! how are you"); 

Does anyone know a solution when and how IOAcknowledge will work?

EDIT: Docs links to the socket library that I am using.

Officially as well as Github

+6
source share
1 answer

It seems that you forgot to call the callback on the server code:

 var io = require('socket.io')(80); io.on('connection', function (socket) { socket.on('sendMessage', function (data, callback) { console.log('Message received:', data); callback('Message successfully delivered to server!'); }); }); 

Check this stream or docs for more information.

EDIT:

The problem also is that the Ack implementation should run as the last emit parameter, so your Java code should look like this:

 socket.emit("sendMessage", "Hi!! how are you", new Ack() { @Override public void call(Object... args) { System.out.println("sendMessage IOAcknowledge" + args.toString()); } }); 
+1
source

All Articles