- deps: remove smallvec deps
- doc: fix some links
- fix: issue #390. First ping was sent twice because of tokio interval behavior defaulting to bursting when interval tick is missed.
- (Breaking): New parsing system. You can now serialize and deserialize binary data inside your own types. It also improve performances by avoiding unnecessary allocations.
- fix: missing extractor error logs for async message handlers.
- feat: add custom compiler error for unimplemented handler traits.
- deps: switch from
tower
totower-service
andtower-layer
subcrates. - deps: bump
tokio
to 1.40. - deps: bump
http
to 1.1. - deps: bump
hyper
to 1.5.
- (Breaking): State reworked to avoid having unsafe global mutable state (issue #317). Therefore State types must now implement
Clone
and will be cloned for each handler where the state is used. - (Breaking): Extensions reworked to avoid
Send
+Sync
requirements on extensions (issue #295). They are now extracted byCloning
. Therefore all the type must implementClone
. AnExtension
extractor is available to get an extension directly without callingsocket.extensions.get()
. - feat: New
HttpExtension
types to extract extensions from the http request. - feat:
SocketIo
can now be used as an extractor. So you can now easily access the entire socket.io context from your handlers. - feat: Dynamic namespaces. You can know set dynamic namespaces with the
dyn_ns
function. You can specify patterns with the{name}
syntax thanks to the matchit crate. The dynamic namespace will create a child namespace for any path that matches the given pattern with the given handler.
- deps: bump
tokio-tungstenite
from0.21.0
to0.23.0
.
- fix: issue #320. Remove unnecessary panic when receiving unexpected websocket messages. This might happen with some specific socket.io clients.
- fix: issue #311, the
delete_ns
fn was deadlocking the entire server when called from inside adisconnect_handler
. - feat: the
delete_ns
is now gracefully closing the adapter as well as all its sockets before being removed. - feat: the API use
Bytes
rather thanVec<u8>
to represent binary payloads. This allow to avoid unnecessary copies. - deps: use
futures-util
andfutures-core
rather than the wholefutures
crate.
- feat: the API use
Bytes/Str
rather thanVec<u8>
andString
to represent payloads. This allow to avoid unnecessary copies. - deps: use
futures-util
andfutures-core
rather than the wholefutures
crate.
MSRV: Minimum supported Rust version is now 1.75.
- (Breaking): Introduction of connect middlewares. It allows to execute code before the connection to the namespace is established. It is useful to check the request, to authenticate the user, to log the connection etc. It is possible to add multiple middlewares and to chain them.
- The
SocketRef
extractor is nowClone
. Be careful to drop clones when the socket is disconnected to avoid any memory leak.
- fix(#232): under heavy traffic, the adjacent binary packet to the head packet requirement for engine.io was not respected. It was leading to a protocol error.
- 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.