Socket.io-client-java: How you remove listeners?

Created on 29 Oct 2014  路  2Comments  路  Source: socketio/socket.io-client-java

You have, for exmaple this:

      socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
        @Override
        public void call(Object... args) {            
            _isConnected = true;      
        }
    });

how you remove that listener?

Best
C

Most helpful comment

You can do the same way with the Javascript client.

// remove all listeners of the connect event
socket.off(Socket.EVENT_CONNECT);

listener = new Emitter.Listener() { ... };
socket.on(Socket.EVENT_CONNECT, listener);
// remove the specified listener
socket.off(Socket.EVENT_CONNECT, listener);

All 2 comments

You can do the same way with the Javascript client.

// remove all listeners of the connect event
socket.off(Socket.EVENT_CONNECT);

listener = new Emitter.Listener() { ... };
socket.on(Socket.EVENT_CONNECT, listener);
// remove the specified listener
socket.off(Socket.EVENT_CONNECT, listener);

Great Thanks.. Works perfectly.. :)

Was this page helpful?
0 / 5 - 0 ratings