Reconnection system using secret for the relay server #46

Merged
CoCo_Sol merged 7 commits from reconnect into main 2024-02-12 22:41:02 +00:00
Showing only changes of commit f76becc2eb - Show all commits

View file

@ -149,7 +149,7 @@ impl Connection {
self.send_sender.send(Message::Binary(data)).ok();
}
/// Receive a message from the target client.
/// Receive a message from the relay connection.
pub fn read(&self) -> Option<(Uuid, Vec<u8>)> {
self.receive_receiver.try_recv().ok()
}
@ -208,7 +208,7 @@ impl Connection {
/// Start the websocket handshake.
fn start_handshake(&mut self, stream: TcpStream) -> ConnectionState {
match tungstenite::client_tls(format!("wss://{}", self.domain), stream) {
Ok((socket, _)) => ConnectionState::Active(socket),
Ok((socket, _)) => ConnectionState::Handshaked(socket),
Err(HandshakeError::Interrupted(handshake)) => ConnectionState::Handshaking(handshake),
Err(HandshakeError::Failure(e)) => {
warn!("handshake failed with the relay server: {e}");