socket.io-client-java icon indicating copy to clipboard operation
socket.io-client-java copied to clipboard

I want to check whether the user is online or not .

Open faziltm opened this issue 9 years ago • 2 comments

I want to check a particular user active or not. For example when i enter a user name. I want to check whether it is active or not. I got the android code is

ChatApplication app = (ChatApplication) getApplication();
mSocket = app.getSocket();
JSONObject user = new JSONObject();
try {
    user.put("userId", "abc");
} catch (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
mSocket.emit("login",user);

And server part code is

socket.on('new user',function(data, callback){ if (nicknames.indexOf(data)!=-1){ callback(false); } else{ callback(true); socket.nickname = data; nicknames.push(socket.nickname); updateNicknames(); } });

But it is not working. emit("login",user); is not showing anything. How to solve this problem? Please help me.

faziltm avatar Apr 07 '17 15:04 faziltm

is resolved your problem?

pishguy avatar May 07 '17 07:05 pishguy

ya, I solve my problem. Thank you.

faziltm avatar May 08 '17 04:05 faziltm