- fix: a panic was raised sometimes under heavy traffic with socketio v5 when the connect timeout handler is destroyed but that the chan sender is still alive.
- (Breaking): Emit errors now contains the provided data if there is an issue with the internal channel (for example if it is full) or if the socket closed.
- (Breaking): Operators are now splitted between
Operators
andBroadcastOperators
in order to split logic and fn signatures between broadcast and non-broadcast operators.
- fix #277: with engine.io v3, the message byte prefix
0x4
was not added to the binary payload withws
transport. - bump dependency
base64
to 0.22.0.
- New
rooms
fn to get all the rooms of a namespace.
- New
as_str
fn forSid
. - Http request is now cloned for the websocket transport (it was not possible before http v1). Therefore it is possible to get headers/extensions of the initial request.
- Rework for
emit_with_ack
fns. It now returns anAckStream
that can be used either as a future when expecting one ack or as a stream when expecting multiple acks. When expecting multiple acks theAckStream
will yieldAckResult
s as well as their corresponding socketid
.
- Add
SocketIo::get_socket
andOperators::get_socket
methods to get a socket ref from its id. - Switch to
pin-project-lite
instead ofpin-project
.
- Bump
hyper
to 1.0.1. Therefore it is now possible to use frameworks based on hyper v1.*. Check the compatibility table for more details.
- Add
transport_type
andprotocol
fn on theSocket
struct. It allows to know the transport type and the protocol used by the socket. - Dynamic
DisconnectHandler
. Now theon_disconnect
handler take a dynamic handler that maybe async and contain any type that implementsFromDisconnectParts
. It allows to extract data from the disconnection, like the socket, the reason of the disconnection, the state etc. - New
state
feature flag. It enables global state management. It is useful to share data between handlers. It is disabled by default.
- Packet encoding/decoding optimizations.
- Fix #189. Async message handlers were never called because the returned future was not spawned with
tokio::spawn
.
- The
on_disconnect
callback now takes aSocketRef
rather than anArc<Socket>
to match other handlers. It also avoids that the user clone the socket and create a memory leak. - Documentation improvements (see https://docs.rs/socketioxide).
- Bump library dependencies (see release notes).
- Fix #154, build was broken when using the
hyper-v1
feature flag because ofhyper-util
dependency which is not published on crates.io.
- The
extensions
field on sockets has been moved to a separate optional feature flag namedextensions
- All the
tracing
internal calls have been moved to a separate optional feature flag namedtracing
- A compatibility layer is now available for hyper v1 under the feature flag
hyper-v1
. You can callwith_hyper_v1
on theSocketIoLayer
or theSocketIoService
to get a layer/service working with hyper v1. Therefore, it is now possible to usesalvo
as an http server. The default is still hyper v0. - Socket.io packet encoding/decoding has been optimized, it is now between ~15% and ~50% faster than before.
- The v5 feature flag is removed, it is now enabled by default. It is made to avoid destructive feature flags, and to be sure that
--no-default-features
will always work without enabling anything else. - All the handlers now have dynamic parameters. It is now possible to use any type that implements
FromMessageParts
orFromMessage
as a parameter for a message handler andFromConnectPart
for a connect handler. This is useful to extract data from the event, like the socket, the data, an acknowledgment, etc. - All the handlers are now optionally async.
- The request data to initialize the socket.io connection is available with
Socket::req_parts()
. - MSRV is now 1.67.0
- Bump tokio from 1.33.0 to 1.34.0
- Bump serde from 1.0.190 to 1.0.192
- Bump serde_json from 1.0.107 to 1.0.108
- All the
tracing
internal calls have been moved to a separate optional feature flag namedtracing
- A compatibility layer is now available for hyper v1 under the feature flag
hyper-v1
. You can callwith_hyper_v1
on theEngineIoLayer
or theEngineIoService
to get a layer/service working with hyper v1. The default is still hyper v0. - Sid generation is now done manually without external crates
- The v4 feature flag is removed, it is now enabled by default. It is made to avoid destructive feature flags, and to be sure that
--no-default-features
will always work without enabling anything else. - Fix an upgrade synchronization bug when using the websocket transport which was leading the client to wait for a ping packet (30s by default) before upgrading to websocket.
- The
on_connect
handler was called twice when upgrading to websocket. It is now called only once.
- New API for creating the socket.io layer/service. A cheaply clonable
SocketIo
struct is now returned with the layer/service and allows to access namespaces/rooms/sockets everywhere in the application. Moreover, it is now possible to add and remove namespaces dynamically through theSocketIo
struct. - The socket.io v4 protocol is now available under the feature flag
v4
, it matches every socket.io js version from 1.0.3 to current . Thev5
protocol is still the default and is more performant, it matches every socket.io js version from v3.0.0 to current.
- The socket parameter for the handler is now an
Arc<Socket>
. - The
max_payload
option is now applied when encoding a packet. Before, it was only applied when decoding a packet. - With
websocket
transport, packets are now bufferred before being flushed. Before, they were flushed one by one.
- Fix a data race bug causing a protocol error when upgrading. A Noop engine.io packet was sent trough the websocket connection after an upgrade. Now all noop packets passing trough the websocket transport are filtered out.
- Fix a bug with binary packets with namespaces : namespace was put before the payload count whereas it should be put after according to the payload datagram.
- A
on_disconnect
function is now available on theSocket
instance. The provided callback will be called when the socket disconnects with the reasons for the disconnection. This is useful for logging or cleanup data. - A
connect_timeout
option is now available in the config options. It is the maximum time to wait for a socket.io handshake before closing the connection. The default is 45 seconds. - A
NsHandlers
struct was added. It describes namespace handlers passed to the SocketIoLayer/SocketIoService. Before, it was a type alias for a HashMap and it was containing types that were not supposed to be public.
- A
DisconnectReason
enum is passed to theon_disconnect
callback of the engine handler. - Bump
tokio-tungstenite
to 0.20.1.