Skip to content

Docs : missing next() function of the middleware in the documentation.#4515

Closed
jacerchetoui56 wants to merge 34 commits intomasterfrom
main
Closed

Docs : missing next() function of the middleware in the documentation.#4515
jacerchetoui56 wants to merge 34 commits intomasterfrom
main

Conversation

@jacerchetoui56
Copy link

A missing next() function in the middleware in the documentation, more specifically in the "Additional attributes" on this link

darrachequesne and others added 30 commits March 30, 2022 08:15
Syntax:

```js
io.timeout(1000).emit("some-event", (err, responses) => {
  // ...
});
```

The adapter exposes two additional methods:

- `broadcastWithAck(packets, opts, clientCountCallback, ack)`

Similar to `broadcast(packets, opts)`, but:

* `clientCountCallback()` is called with the number of clients that
  received the packet (can be called several times in a cluster)
* `ack()` is called for each client response

- `serverCount()`

It returns the number of Socket.IO servers in the cluster (1 for the
in-memory adapter).

Those two methods will be implemented in the other adapters (Redis,
Postgres, MongoDB, ...).

Related:

- #1811
- #4163
- socketio/socket.io-redis-adapter#445
This is similar to `onAny()`, but for outgoing packets.

Syntax:

```js
socket.onAnyOutgoing((event, ...args) => {
  console.log(event);
});
```
This commit handles several edge cases that were silently ignored
before:

- receiving several CONNECT packets during a session
- receiving any packet without CONNECT packet first
Calling `socket.join()` after disconnection would lead to a memory
leak, because the room was never removed from the memory:

```js
io.on("connection", (socket) => {
  socket.disconnect();
  socket.join("room1"); // leak
});
```

Related:

- #4067
- #4380
Production:

- socket.io-parser: ~4.0.4 => ~4.2.0

Development:

- superagent: ^6.1.0 => ^8.0.0
- tsd: ^0.17.0 => ^0.21.0

Related: #3709
This should fix a rare case where the Engine.IO connection was upgraded
to WebSocket while the Socket.IO socket was disconnected, which would
result in the following exception:

> TypeError: Cannot read properties of undefined (reading 'forEach')
>    at subscribe (/node_modules/socket.io/dist/uws.js:87:11)
>    at Socket.<anonymous> (/node_modules/socket.io/dist/uws.js:28:17)
>    at Socket.emit (node:events:402:35)
>    at WebSocket.onPacket (/node_modules/engine.io/build/socket.js:214:22)
>    at WebSocket.emit (node:events:390:28)
>    at WebSocket.onPacket (/node_modules/engine.io/build/transport.js:92:14)
>    at WebSocket.onData (/node_modules/engine.io/build/transport.js:101:14)
>    at message (/node_modules/engine.io/build/userver.js:56:30)

Related: #4443
Note: some disconnection reasons could be merged in the next major
release, i.e. the Deno impl does not have "forced server close" and
"server shutting down"

Related: #4387
Typed events were not applied when calling "io.timeout(...).emit()".

Related: socketio/socket.io-client#1555 (comment)

Reference: https://socket.io/docs/v4/typescript/
@jacerchetoui56 jacerchetoui56 changed the title missing next() function of the middleware in the documentation. Docs : missing next() function of the middleware in the documentation. Nov 8, 2022
@darrachequesne
Copy link
Member

@jacerchetoui56 Hi! Thanks for the pull request. It seems something is not right here, could you please check? Were you looking for the https://github.com/socketio/socket.io-website repository instead?

@darrachequesne
Copy link
Member

Closed due to inactivity, please reopen if needed.

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.

9 participants