diff --git a/server/stat/src/main.rs b/server/stat/src/main.rs index 6cd9336..fe81c42 100755 --- a/server/stat/src/main.rs +++ b/server/stat/src/main.rs @@ -82,16 +82,7 @@ impl MyWs { tmp_bytes.put_u16_le(magic_code); tmp_bytes.put_u16_le(ext_len); tmp_bytes.put_i32_le(0); - //tmp_bytes.put_u16_le(0); - //tmp_bytes.put_u16_le(0); tmp_bytes.put_i64_le(0); - /*tmp_bytes.put_u16(0); - tmp_bytes.put_u16(0); - tmp_bytes.put_i32(0); - tmp_bytes.put_u16(0); - tmp_bytes.put_u16(0); - tmp_bytes.put_i32(0); - tmp_bytes.put_i64(0);*/ for i in 24..tmp_bytes.capacity() { tmp_bytes.put_i8(0); } @@ -146,7 +137,6 @@ impl StreamHandler> for MyWs { data: a_bytes }; a.send(msg); - //ctx.binary(a_bytes); } } tokio::time::sleep(Duration::from_millis(10)).await; @@ -235,7 +225,11 @@ async fn index(req: HttpRequest, stream: web::Payload, data: web::Data { println!("read {} bytes", n); - let mut tmp_bytes = BytesMut::with_capacity((n + 24) as usize); + let mut tmp_bytes = BytesMut::with_capacity((n + 0) as usize); + for i in 0..n { + tmp_bytes.put_u8(data[i]); + } + Arc::downgrade(&mut recv_queue).upgrade().unwrap().lock().unwrap().borrow_mut().insert(0, tmp_bytes); } Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { println!("read error 1");