mirror of
https://github.com/actix/actix-web.git
synced 2024-12-18 14:16:47 +00:00
Customize websocket max size
This commit is contained in:
parent
82920e1ac1
commit
5482d64df5
1 changed files with 12 additions and 2 deletions
|
@ -171,18 +171,28 @@ pub enum Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do websocket handshake and start actor
|
/// Do websocket handshake and start actor
|
||||||
pub fn start<A, S>(req: &HttpRequest<S>, actor: A) -> Result<HttpResponse, Error>
|
#[inline]
|
||||||
|
pub fn create<A, S>(req: &HttpRequest<S>, actor: A, max_size: usize) -> Result<HttpResponse, Error>
|
||||||
where
|
where
|
||||||
A: Actor<Context = WebsocketContext<A, S>> + StreamHandler<Message, ProtocolError>,
|
A: Actor<Context = WebsocketContext<A, S>> + StreamHandler<Message, ProtocolError>,
|
||||||
S: 'static,
|
S: 'static,
|
||||||
{
|
{
|
||||||
let mut resp = handshake(req)?;
|
let mut resp = handshake(req)?;
|
||||||
let stream = WsStream::new(req.payload());
|
let stream = WsStream::new(req.payload()).max_size(max_size);
|
||||||
|
|
||||||
let body = WebsocketContext::create(req.clone(), actor, stream);
|
let body = WebsocketContext::create(req.clone(), actor, stream);
|
||||||
Ok(resp.body(body))
|
Ok(resp.body(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Do websocket handshake and start actor
|
||||||
|
pub fn start<A, S>(req: &HttpRequest<S>, actor: A) -> Result<HttpResponse, Error>
|
||||||
|
where
|
||||||
|
A: Actor<Context = WebsocketContext<A, S>> + StreamHandler<Message, ProtocolError>,
|
||||||
|
S: 'static,
|
||||||
|
{
|
||||||
|
create(req, actor, 65_536)
|
||||||
|
}
|
||||||
|
|
||||||
/// Prepare `WebSocket` handshake response.
|
/// Prepare `WebSocket` handshake response.
|
||||||
///
|
///
|
||||||
/// This function returns handshake `HttpResponse`, ready to send to peer.
|
/// This function returns handshake `HttpResponse`, ready to send to peer.
|
||||||
|
|
Loading…
Reference in a new issue