Spec-Zone.ru › Socket.IO 4

Offline behavior

Buffered events

By default, any event emitted while the Socket is not connected will be buffered until reconnection.

While useful in most cases (when the reconnection delay is short), it could result in a huge spike of events when the connection is restored.

There are several solutions to prevent this behavior, depending on your use case:

  • use the connected attribute of the Socket instance
if (socket.connected) {
  socket.emit( /* ... */ );
} else {
  // ...
}
  • use volatile events
socket.volatile.emit( /* ... */ );

© 2014–2021 Automattic
Licensed under the MIT License.
https://socket.io/docs/v4/client-offline-behavior

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API