Q:

Socket.io java client get same message more than one time

I am using socket.io on my android chat application. In order to keep connection alive, I am connecting socket in a service which is started in main activity. And I check if socket is connected. If it is not, I make socket connection. Here is my codes:
try {
        mSocket = IO.socket("http://192.168.x.x:XXXX");
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }

    if(!mSocket.connected()){   
        mSocket.connect();
    }

    mSocket.on("new message", onNewMessage);
    mSocket.on("user joined", onUserJoined);
    mSocket.emit("add user", "MobileUser");

    message += cal.get(Calendar.HOUR) + ":" + cal.get(Calendar.MINUTE);
    sendMessage();

public void sendMessage(){
     mSocket.emit("new message", message);
     addMessage("MobileUser", message);
}

Connections works perfectly. My service sends message using socket in every minute. This seems like this in an other client:
MobileUser: 1:11
MobileUser: 1:12
MobileUser: 1:13
MobileUser: 1:14
MobileUser: 1:15

Here is my problem: After these 5 messages  ( 5 times is just an example, it could be any number more than 1), if an other client sends message, I get this message for 5 times. But of course I want to get this message for once. How can I handle with this problem? Any suggestions?
Edit:
My onNewMessage Method is on client side:
private Emitter.Listener onNewMessage = new Emitter.Listener() {
public void call(final Object... args) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            JSONObject data = (JSONObject) args[0];
            try {
                username = data.getString("username");
                message = data.getString("message");
            } catch (JSONException e) {
                return;
            }

            Log.v(username, message);
        }
    });

    t.start();
  }
};

And the "new message" event on my server:
socket.on('new message', function (data) {
   console.log('message: ' + data);

   socket.broadcast.emit('new message', {
      username: socket.username,
      message: data
   });
});

A:

I think I found the solution. I should check if socket is connected or not in my service class but these codes shouldn't be in there: 
mSocket.on("new message", onNewMessage);
mSocket.on("user joined", onUserJoined);
mSocket.emit("add user", "MobileUser");

I removed these from my service class and put the MainActivity class. Problem is solved.

