Unverified Commit a0813cbd authored by Alexandru Vasile's avatar Alexandru Vasile Committed by GitHub
Browse files

Implement `ping-pong` for WebSocket clients (#772)



* ws: Implement ping for `TransportSenderT` trait

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* ws/client: Receive pong frames

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* core/client: Use `select!` macro for the background task

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Propagate ping interval to background task

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* async_client: Submit ping requests

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* async_client: Handle pong replies

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Handle frontend messages to dedicated fn

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Handle backend messages in dedicated fn

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Add terminated fuse for opt-out pings

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Set opt-out behavior for client pings

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Move imports

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Handle handle_frontend_messages errors

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Add custom error related to byteslice conversions

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Modify `send_ping` to send empty slices

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Fix `cargo hack check` and use `select_biased`

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Handle sending pings with lowest priority

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* core: Add proper number of params to `background_task`

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Fix wasm client

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Handle raw bytes and string received messages

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Fix Cargo.toml feature

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Panic when empty slice does not fit into `ByteSlice125`

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* wasm: Add operation not supported for pings

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Rename `ReceivedMessage` from Data to Text

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Rename test variable

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Add documentation

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Use `future::select` for  cancel safety

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Remove `pong` handling logic

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* client: Update ping documentation

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Update core/src/client/async_client/mod.rs

Co-authored-by: default avatarTarik Gul <[email protected]>

* Update core/src/client/async_client/mod.rs

Co-authored-by: default avatarTarik Gul <[email protected]>

* Update core/src/client/async_client/mod.rs

Co-authored-by: default avatarTarik Gul <[email protected]>

* Update core/src/client/async_client/mod.rs

Co-authored-by: default avatarTarik Gul <[email protected]>

* Update core/src/client/async_client/mod.rs

Co-authored-by: default avatarTarik Gul <[email protected]>

* Update core/Cargo.toml

Co-authored-by: default avatarNiklas Adolfsson <[email protected]>

* Update core/Cargo.toml

Co-authored-by: default avatarNiklas Adolfsson <[email protected]>

* logs: Keep debug log for submitting `Ping` frames

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Print debug logs when receiving `Pong` frames

Signed-off-by: default avatarAlexandru Vasile <[email protected]>

* Update core/src/client/async_client/mod.rs

Co-authored-by: default avatarTarik Gul <[email protected]>
Co-authored-by: default avatarNiklas Adolfsson <[email protected]>
parent 2ac4cb26
Pipeline #196851 passed with stages
in 5 minutes and 27 seconds