I am trying to send a message from my server made in nodejs, when I start my server the message I show it in console but I want to know how I have that message displayed on my android smartphone
this is what I have
server:
var array = {"nombre":"jorge pedro"};
io.on('connection',function(socket){
socket.broadcast.emit('primero',array);
console.log(array);
socket.on('disconnect',function(){
console.log('Usuario desconectado con id: '+socket.id);
})
})
and this I do in my java class
socket.on("primero", ver);
private Emitter.Listener ver = new Emitter.Listener(){
@Override
public void call(Object... args) {
JSONObject data = (JSONObject) args[0];
String message;
try {
message = data.getString("nombre").toString();
Toast.makeText(Menu.this,message,Toast.LENGTH_LONG).show();
} catch (JSONException e) {
// return;
}
}
};
}
The idea is that when a phone connects to the server, it sends the array and I get this error Can not create handler inside thread that has not called Looper.prepare ()
How can I solve it? I thank you in advance for your help
socketio of com.github.nkzawa: socket.io-client: 0.5.0 for android