Skip to content

Use client function to unify client in test script #2731

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

Merged
merged 1 commit into from
Oct 24, 2016
Merged

Use client function to unify client in test script #2731

merged 1 commit into from
Oct 24, 2016

Conversation

bananaappletw
Copy link
Contributor

I recreated the pull request.
cc: @darrachequesne

var addr = srv.listen().address();
var url = 'ws://localhost:' + addr.port + '?key1=1&key2=2';
var socket = ioc(url);
var socket = client(srv, {query: {key1: 1, key2: 2}});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the meaning of the test updated there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.
Actually, this is the same meaning as the previous test.
This pull request just simplify the code.

Copy link
Contributor Author

@bananaappletw bananaappletw Oct 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at socket.io-client.
https://github.com/socketio/socket.io-client/blob/master/lib/index.js#L44
In here, the query is parsed from the uri.
You could simply add debug code in socket.io-client to see the value of opts.query.
Eventually, they are parsed as the same value.
That's key1=1&key2=2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass {query: {key1: 1, key2: 2} to socket.io-client.
https://github.com/socketio/socket.io-client/blob/master/lib/index.js#L76
This function will turn query into key1=1&key2=2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darrachequesne darrachequesne merged commit 5c10c54 into socketio:master Oct 24, 2016
@darrachequesne
Copy link
Member

@bananaappletw thanks!!

@darrachequesne darrachequesne added this to the 1.5.1 milestone Oct 24, 2016
dzad pushed a commit to dzad/socket.io that referenced this pull request May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants