mirror of
https://github.com/actix/actix-website
synced 2024-11-24 00:41:07 +01:00
ab7ce01131
* chore(deps): bump actix-web-actors in /examples Bumps [actix-web-actors](https://github.com/actix/actix-web) from 4.3.0 to 4.3.1+deprecated. - [Release notes](https://github.com/actix/actix-web/releases) - [Changelog](https://github.com/actix/actix-web/blob/master/CHANGES.md) - [Commits](https://github.com/actix/actix-web/compare/web-v4.3.0...web-v4.3.1) --- updated-dependencies: - dependency-name: actix-web-actors dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * docs: update websockets docs to use actix-ws --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede <robjtede@icloud.com>
23 lines
944 B
Markdown
23 lines
944 B
Markdown
---
|
|
title: WebSockets
|
|
---
|
|
|
|
import CodeBlock from "@site/src/components/code_block";
|
|
|
|
# WebSockets
|
|
|
|
Actix Web supports a high-level WebSocket interface via the `actix-ws` crate. Using this crate, it's possible to convert a request's `Payload` stream into a stream of [_ws::Message_][message]s and then react to them inside a spawned async task.
|
|
|
|
The following is an example of a simple WebSocket echo server:
|
|
|
|
<CodeBlock example="websockets" file="main.rs" section="websockets" />
|
|
|
|
> A simple WebSocket echo server example is available [in the examples repo][echo].
|
|
|
|
> An example chat server is also available [in the examples directory][chat]
|
|
|
|
[message]: https://docs.rs/actix-ws/0.3/actix_ws/enum.Message.html
|
|
[payload]: https://docs.rs/actix-web/4/actix_web/web/struct.Payload.html
|
|
[echo]: https://github.com/actix/examples/tree/master/websockets/echo-actorless
|
|
[chat]: https://github.com/actix/examples/tree/master/websockets/chat-actorless
|