added extra logging
This commit is contained in:
parent
11f3745adb
commit
69c9664eb5
1 changed files with 30 additions and 25 deletions
55
src/lib.rs
55
src/lib.rs
|
@ -86,34 +86,39 @@ pub async fn send_to_wc_task(
|
||||||
mut sender: SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, tokio_tungstenite::tungstenite::Message>
|
mut sender: SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, tokio_tungstenite::tungstenite::Message>
|
||||||
) {
|
) {
|
||||||
info!("From app is closed: {:?}", from_app.is_closed());
|
info!("From app is closed: {:?}", from_app.is_closed());
|
||||||
while let Ok(msg) = from_app.recv().await {
|
loop {
|
||||||
#[cfg(debug_assertions)]
|
match from_app.recv().await {
|
||||||
{
|
Ok(msg) => {
|
||||||
info!("Sending message to socket!");
|
#[cfg(debug_assertions)]
|
||||||
// serialized message
|
{
|
||||||
match serde_json::to_string(&msg) {
|
info!("Sending message to socket!");
|
||||||
Err(e) => error!("Could not serialize ApplicationMessage to JSON! {e}"),
|
// serialized message
|
||||||
Ok(msg) => {
|
match serde_json::to_string(&msg) {
|
||||||
if let Err(e) = sender.send(Message::text(msg)).await {
|
Err(e) => error!("Could not serialize ApplicationMessage to JSON! {e}"),
|
||||||
error!("Could not send text ApplicationMessage to websocket! Closing websocket\n{e}");
|
Ok(msg) => {
|
||||||
break;
|
if let Err(e) = sender.send(Message::text(msg)).await {
|
||||||
}
|
error!("Could not send text ApplicationMessage to websocket! Closing websocket\n{e}");
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
}
|
||||||
{
|
|
||||||
match bincode::serialize(&msg) {
|
#[cfg(not(debug_assertions))]
|
||||||
Err(e) => error!("Could not serialize ApplicationMessage into binary! {e}"),
|
{
|
||||||
Ok(e) => {
|
match bincode::serialize(&msg) {
|
||||||
if let Err(e) = sender.send(Message::binary(msg)).await {
|
Err(e) => error!("Could not serialize ApplicationMessage into binary! {e}"),
|
||||||
error!("Could not send binary ApplicationMessage to websocket! Closing websocket\n{e}");
|
Ok(e) => {
|
||||||
break;
|
if let Err(e) = sender.send(Message::binary(msg)).await {
|
||||||
|
error!("Could not send binary ApplicationMessage to websocket! Closing websocket\n{e}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(e) => error!("Send to WC had a recv error! {e}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue