Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WsResponseBuilder to build web socket session response #1920

Merged
merged 11 commits into from Dec 4, 2021

Conversation

sazid
Copy link
Contributor

@sazid sazid commented Jan 21, 2021

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt
  • (Team) Label with affected crates and semver status.

Overview

New: You can now start a websocket session with a frame size or a actix_http::ws::Codec by using the ws:WsResponseBuilder.

Example:

const MAX_FRAME_SIZE: usize = 10_000;
ws::WsResponseBuilder::new(WsActor, &req, stream)
    .codec(Codec::new()) // optional
    .protocols(&["A", "B"]) // optional
    .frame_size(MAX_FRAME_SIZE) // optional
    .start()

There are two terminal methods for the builder. This is in line with two existing start() and start_with_addr() fns.

  • start() which starts the actor and returns a response.
  • start_with_addr() which starts the actor and returns both the addr of the actor and the response.

Fixes #1873

actix-web-actors/CHANGES.md Outdated Show resolved Hide resolved
actix-web-actors/src/ws.rs Outdated Show resolved Hide resolved
Copy link
Member

@robjtede robjtede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like to see one test where the frame size is exceeded producing an error

actix-web-actors/src/ws.rs Outdated Show resolved Hide resolved
@brockelmore
Copy link

brockelmore commented Jul 19, 2021

Any update on this PR/when it will land? Seems stale, can fill in and complete any tasks that remain to be done

Edit: ping on this, definitively stale at this point, how can I step in to push it along?

@robjtede robjtede added this to the actix-web v4 milestone Nov 25, 2021
@robjtede
Copy link
Member

robjtede commented Dec 4, 2021

thanks for getting this started @sazid and for everyone else's patience :)

@robjtede robjtede merged commit 4c9ca71 into actix:master Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-actors project: actix-web-actors B-semver-minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

expose some way to alter websocket frame size limit
3 participants