remove Arc from WebSocket Connection

This commit is contained in:
Vinzenz Schroeter 2024-11-13 18:29:48 +01:00
parent bb34541077
commit 3d74bfe05e

View file

@ -34,11 +34,9 @@ pub enum Connection {
/// [servicepoint-websocket-relay]: https://github.com/kaesaecracker/servicepoint-websocket-relay /// [servicepoint-websocket-relay]: https://github.com/kaesaecracker/servicepoint-websocket-relay
#[cfg(feature = "protocol_websocket")] #[cfg(feature = "protocol_websocket")]
WebSocket( WebSocket(
std::sync::Arc< std::sync::Mutex<
std::sync::Mutex< tungstenite::WebSocket<
tungstenite::WebSocket< tungstenite::stream::MaybeTlsStream<std::net::TcpStream>,
tungstenite::stream::MaybeTlsStream<std::net::TcpStream>,
>,
>, >,
>, >,
), ),
@ -109,9 +107,9 @@ impl Connection {
let request = ClientRequestBuilder::new(uri).into_client_request()?; let request = ClientRequestBuilder::new(uri).into_client_request()?;
let (sock, _) = connect(request)?; let (sock, _) = connect(request)?;
Ok(Self::WebSocket(std::sync::Arc::new(std::sync::Mutex::new( Ok(Self::WebSocket(std::sync::Mutex::new(
sock, sock,
)))) )))
} }
/// Send something packet-like to the display. Usually this is in the form of a Command. /// Send something packet-like to the display. Usually this is in the form of a Command.
@ -163,7 +161,7 @@ impl Drop for Connection {
if let Connection::WebSocket(sock) = self { if let Connection::WebSocket(sock) = self {
_ = sock _ = sock
.try_lock() .try_lock()
.map(move |mut sock| sock.close(None).unwrap()); .map(move |mut sock| sock.close(None));
} }
} }
} }