I am trying to do an android application using node.js server. In android code, socket.emit functions works well. However emit listenner(socket.on) doesn't respond. Android code is as follows;
private Emitter.Listener getbrowser1f = new Emitter.Listener() {
@Override
public void call(final Object... args) {
//I want this place work. but it doesnt
}
};
function doesn't respond. I am triggering getbrowser1 using this code on android,
socket.emit("getbrowser1","msg1");
related app.js code is as follows
socket.on('getbrowser1', function (data) {
io.sockets.emit('getbrowser1f', a );
});
In javascript, I could easly use
socket.on('getbrowser1f' function(data){
});
and it works well but in android this is not the correct way to code it.
Problem solved after I made change in emit listener as in following code;
socket.on("getbrowser1f", new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.d(TAG, "object.event");
socket.emit("doit2","msg2");
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.