Socket.io-client-java: Why some EVENTs are removed in v2?

Created on 15 Dec 2020  路  4Comments  路  Source: socketio/socket.io-client-java

EVENT_RECONNECT_ERROR? EVENT_CONNECTING? EVENT_CONNECT_TIMEOUT? and etc...

I was wondering why you removed these EVENTS, these are so important for some if not all.

question

Most helpful comment

All 4 comments

Hi! Those events were not removed per se, they are not forwarded by the Socket instance anymore, but they are still emitted by the underlying Manager.

Before:

socket.on(Socket.EVENT_RECONNECT_ATTEMPT, new Emitter.Listener() {
    @Override
    public void call(Object... objects) {
        // ...
    }
});

After:

socket.io().on(Manager.EVENT_RECONNECT_ATTEMPT, new Emitter.Listener() {
    @Override
    public void call(Object... objects) {
        // ...
    }
});

The reason behind this change was to make the existence of the Manager explicit for the end users, and to fix some surprising behavior, like:

socket.on(Socket.EVENT_RECONNECT, new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        System.out.println(socket.connected()); // false ???
    }
});

Added here: http://socketio.github.io/socket.io-client-java/migrating_from_1_x.html#The_Socket_instance_will_no_longer_forward_the_events_emitted_by_its_Manager

Hi! Those events were not removed per se, they are not forwarded by the Socket instance anymore, but they are still emitted by the underlying Manager.

Before:

socket.on(Socket.EVENT_RECONNECT_ATTEMPT, new Emitter.Listener() {
    @Override
    public void call(Object... objects) {
        // ...
    }
});

After:

socket.io().on(Manager.EVENT_RECONNECT_ATTEMPT, new Emitter.Listener() {
    @Override
    public void call(Object... objects) {
        // ...
    }
});

The reason behind this change was to make the existence of the Manager explicit for the end users, and to fix some surprising behavior, like:

socket.on(Socket.EVENT_RECONNECT, new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        System.out.println(socket.connected()); // false ???
    }
});

Added here: http://socketio.github.io/socket.io-client-java/migrating_from_1_x.html#The_Socket_instance_will_no_longer_forward_the_events_emitted_by_its_Manager

Thanks for clarifying mate, I appreciate your work.

Keep it up 馃憤

Thanks! And EVENT_CONNECT_TIMEOUT disappeared.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaumard picture jaumard  路  4Comments

mrgame64 picture mrgame64  路  10Comments

forlayo picture forlayo  路  5Comments

abhilash29 picture abhilash29  路  6Comments

jukbot picture jukbot  路  3Comments