Refactoring

This commit is contained in:
2021-05-22 10:58:47 +02:00
parent 912f2f0bf3
commit f2a6a5af4e
4 changed files with 66 additions and 55 deletions

View File

@ -1,8 +1,13 @@
mod handler;
pub use handler::*;
use crate::http::Stream;
use crate::error::Error;
use crate::http;
pub use handler::*;
pub struct WebSocketStream {
stream: http::HttpStream,
compression: bool,
}
pub struct FrameHeader {
fin: bool,
@ -17,7 +22,7 @@ pub struct FrameHeader {
}
impl FrameHeader {
pub fn from(socket: &mut Stream) -> Result<Self, Error> {
pub fn from(socket: &mut http::Stream) -> Result<Self, Error> {
let mut data = [0u8; 2];
socket.read_exact(&mut data)?;
@ -44,7 +49,7 @@ impl FrameHeader {
}
if header.mask {
let mut data =[0u8; 4];
let mut data = [0u8; 4];
socket.read_exact(&mut data)?;
header.masking_key = Some(u32::from_be_bytes(data));
}