AndroidAsync Socket.IO receive callback value

2019-08-27 07:05发布

I'm trying to build an application for Android using this library: https://github.com/koush/AndroidAsync and I was trying to receive a callback value from the server like this but the app crashes:

  client.emit("callbackTry", new Acknowledge() {
        @Override
        public void acknowledge(JSONArray arg0) {
            Log.e(TAG,"acknowledge: "+ arg0);
        }
  });

I leave you the server-side:

socket.on('callbackTry', function (callback) {
    console.log(callback);
    var hello = "Hello";
    callback(hello);
});

How can I return the data back to the client?

1条回答
女痞
2楼-- · 2019-08-27 07:58

I found a solution myself which consists on changing emit method to emitEvent. Hope it really help someone else too.

查看更多
登录 后发表回答