I have a server developed with NodeJS, Socket.IO and Express. I developed a website to deal against that server and works all fine. The trouble comes when I tried to develop an android application.
I have a method on socket.io that returns an array of objects with. In code is like:
socket.on("getData",function(data){
if(data!=null){
io.sockets.connected.emit("getSocData", {result:true});
}
}
In the client, in js, where is working fine.
socket.on("getSocData", function (data) {
if(data){alert("good"); }
}
The trouble comes when I debug the Android app, where the code is:
mSocket.on("getSocData", new Emitter.Listener() {
@Override
public void call(final Object.. args) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
JSONObject data = (JSONObject) args[0];
}
});
}
});
When I debug that Android code with my mobile, start looping the run method more than 20 times, although the mSocket.on only is triggering one time.
I am getting crazy because in website is working fine but in Android freezes the app until the run method stop.
The dependecy that I use is:
compile ('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}
Thx 4 all guys!
via kartGIS
No comments:
Post a Comment