Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More control over auth property #780

Open
magyarlaszlo opened this issue Feb 20, 2025 · 2 comments
Open

More control over auth property #780

magyarlaszlo opened this issue Feb 20, 2025 · 2 comments

Comments

@magyarlaszlo
Copy link

magyarlaszlo commented Feb 20, 2025

Hello!

I would like to request a small change regarding the auth parameter. Currently, it is limited to a Map<String, String>, but for my use-case it would be nice to have more control over it. As I can see in the code, this map is converted into a JSONObject before it is being sent.

My request would be to change the Manager.Options class' auth property to a JSONObject, so I can send anything I want in auth, not just a map of strings. After the change, the Manager.Options class would look like this:

`
public static class Options extends io.socket.engineio.client.Socket.Options {

    public boolean reconnection = true;
    public int reconnectionAttempts;
    public long reconnectionDelay;
    public long reconnectionDelayMax;
    public double randomizationFactor;
    public Parser.Encoder encoder;
    public Parser.Decoder decoder;
    public JSONObject auth;

    /**
     * Connection timeout (ms). Set -1 to disable.
     */
    public long timeout = 20000;

    // helper method for easier migration
    public void authMap(Map<String, String> authMap) {
        this.auth = new JSONObject(authMap);
    }
}`

Also, the Socket class needs a little change:
`
private final JSONObject auth;

private void onopen() {
    logger.fine("transport is open - connecting");

    if (this.auth != null) {
        this.packet(new Packet<>(Parser.CONNECT, this.auth));
    } else {
        this.packet(new Packet<>(Parser.CONNECT));
    }
}`

Thanks in advance!

@laszlomagyardocler
Copy link

laszlomagyardocler commented Feb 21, 2025

I created a pull request with the required changes here: #781

@kyrylzotov
Copy link

We need the same changes to make it more extensive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants