AndroidAsync Socket.IO接收回值 [英] AndroidAsync Socket.IO receive callback value
本文介绍了AndroidAsync Socket.IO接收回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图建立使用这个库为Android的应用程序: https://github.com/koush/ AndroidAsync 我试图接收来自这样服务器的回调值,但应用程序崩溃:
client.emit(callbackTry,新的应答(){
@覆盖
公共无效确认(JSONArray为arg0){
Log.e(TAG,承认:+为arg0);
}
});
块引用>我离开你的服务器端:
socket.on('callbackTry',函数(回调){
的console.log(回调);
VAR你好=你好;
回调(你好);
});
块引用>我怎样才能返回数据返回给客户端?
解决方案我发现了一个解决方案,我其中包括关于改变EMIT方法emitEvent。希望它真的帮助别人了。
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?
解决方案I found a solution myself which consists on changing emit method to emitEvent. Hope it really help someone else too.
这篇关于AndroidAsync Socket.IO接收回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文