1
This commit is contained in:
parent
b8eb286d0a
commit
b87ad6eaa6
@ -126,18 +126,33 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for MyWs {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
while Arc::downgrade(&mut recv_queue).upgrade().unwrap().lock().unwrap().borrow().len() > 0 {
|
while Arc::downgrade(&mut recv_queue).upgrade().unwrap().lock().unwrap().borrow().len() > 0 {
|
||||||
let bytes = Arc::downgrade(&mut recv_queue).upgrade().unwrap().lock().unwrap().borrow_mut().pop();
|
let bytes = Arc::downgrade(&mut recv_queue).upgrade().unwrap().lock().unwrap().borrow_mut().pop().clone();
|
||||||
let len = bytes.clone().unwrap().clone().len();
|
let len = bytes.clone().unwrap().clone().len();
|
||||||
{
|
{
|
||||||
println!("sendmsg len:{0}", len);
|
println!("sendmsg len:{0}", len);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
let data = bytes.unwrap();
|
||||||
|
let pack_len = (data.as_ref()[0] as u16)+ ((data.as_ref()[1] as u16) << 8);
|
||||||
|
let msg_id = (data.as_ref()[2] as u16)+ ((data.as_ref()[3] as u16) << 8);
|
||||||
|
let seq_id = (data.as_ref()[4] as i32)+ ((data.as_ref()[5] as i32) << 8) +
|
||||||
|
((data.as_ref()[7] as i32) << 16)+ ((data.as_ref()[7] as i32) << 24);
|
||||||
|
let magic_code = (data.as_ref()[8] as u16)+ ((data.as_ref()[9] as u16) << 8);
|
||||||
|
let rpc_error_code = (data.as_ref()[10] as u16)+ ((data.as_ref()[11] as u16) << 8);
|
||||||
|
let socket_handle = (data.as_ref()[12] as u16)+ ((data.as_ref()[13] as u16) << 8);
|
||||||
|
let ext_len = (data.as_ref()[14] as u16)+ ((data.as_ref()[15] as u16) << 8);
|
||||||
|
if (pack_len + 16) as usize != data.len() {
|
||||||
|
panic!("errro len");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
let mut a_bytes = actix_web::web::Bytes::copy_from_slice(bytes.unwrap().as_ref());
|
let mut a_bytes = actix_web::web::Bytes::copy_from_slice(bytes.unwrap().as_ref());
|
||||||
let msg = GSResponse {
|
let msg = GSResponse {
|
||||||
data: a_bytes
|
data: a_bytes
|
||||||
};
|
};
|
||||||
a.send(msg);
|
a.send(msg);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user