-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove the implicit connection to the default namespace
In previous versions, a client was always connected to the default namespace, even if it requested access to another namespace. This meant that the middlewares registered for the default namespace were triggered in any case, which is a surprising behavior for end users. This also meant that the query option of the Socket on the client-side was not sent in the Socket.IO CONNECT packet for the default namespace: ```js // default namespace: query sent in the query params const socket = io({ query: { abc: "def" } }); // another namespace: query sent in the query params + the CONNECT packet const socket = io("/admin", { query: { abc: "def" } }); ``` The client will now send a CONNECT packet in any case, and the query option of the Socket is renamed to "auth", in order to make a clear distinction with the query option of the Manager (included in the query parameters of the HTTP requests). ```js // server-side io.use((socket, next) => { // not triggered anymore }); io.of("/admin").use((socket, next => { // triggered console.log(socket.handshake.query.abc); // "def" console.log(socket.handshake.auth.abc); // "123" }); // client-side const socket = io("/admin", { query: { abc: "def" }, auth: { abc: "123" } }); ```
- Loading branch information
1 parent
6f9ca62
commit 09b6f23
Showing
13 changed files
with
85 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.