mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
aquatic_ws: use fn handle_handshake_result in one more location
This commit is contained in:
parent
583d323c7f
commit
656b0da3c6
1 changed files with 10 additions and 33 deletions
|
|
@ -307,42 +307,19 @@ pub fn read_and_forward_in_messages(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ConnectionStage::MidHandshake(mut handshake) => {
|
ConnectionStage::MidHandshake(handshake) => {
|
||||||
let stream = handshake.get_mut().get_mut();
|
let stop_loop = handle_handshake_result(
|
||||||
let peer_socket_addr = stream.peer_addr().unwrap();
|
connections,
|
||||||
|
poll_token,
|
||||||
|
valid_until,
|
||||||
|
handshake.handshake()
|
||||||
|
);
|
||||||
|
|
||||||
match handshake.handshake(){
|
if stop_loop {
|
||||||
Ok(ws) => {
|
break;
|
||||||
println!("handshake established");
|
|
||||||
let peer_connection = PeerConnection {
|
|
||||||
ws,
|
|
||||||
peer_socket_addr,
|
|
||||||
valid_until,
|
|
||||||
};
|
|
||||||
|
|
||||||
let connection = Connection {
|
|
||||||
valid_until: Some(valid_until),
|
|
||||||
stage: ConnectionStage::Established(peer_connection)
|
|
||||||
};
|
|
||||||
|
|
||||||
connections.insert(poll_token, connection);
|
|
||||||
},
|
|
||||||
Err(HandshakeError::Interrupted(handshake)) => {
|
|
||||||
let connection = Connection {
|
|
||||||
valid_until: Some(valid_until),
|
|
||||||
stage: ConnectionStage::MidHandshake(handshake),
|
|
||||||
};
|
|
||||||
|
|
||||||
connections.insert(poll_token, connection);
|
|
||||||
|
|
||||||
break;
|
|
||||||
},
|
|
||||||
Err(HandshakeError::Failure(err)) => {
|
|
||||||
dbg!(err);
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
ConnectionStage::Established(_) => unreachable!(),
|
||||||
}
|
}
|
||||||
} else if let Some(Connection{
|
} else if let Some(Connection{
|
||||||
stage: ConnectionStage::Established(peer_connection),
|
stage: ConnectionStage::Established(peer_connection),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue