trying to fix udp telegram
This commit is contained in:
@@ -44,7 +44,7 @@ pub(crate) async fn run_tcp_bridge<R, W>(
|
||||
maybe_data = v_rx.recv() => {
|
||||
match maybe_data {
|
||||
Some(data) => {
|
||||
if data.is_empty() { break; }
|
||||
if data.is_empty() { continue; }
|
||||
if let Err(e) = writer.write_all(&data).await {
|
||||
error!(stream_id, error = %e, "Socket write error");
|
||||
break;
|
||||
@@ -103,7 +103,6 @@ pub(crate) async fn run_udp_bridge(
|
||||
maybe_data = v_rx.recv() => {
|
||||
match maybe_data {
|
||||
Some(data) => {
|
||||
if data.is_empty() { break; }
|
||||
if let Err(e) = socket.send(&data).await {
|
||||
error!(stream_id, error = %e, "UDP socket write error");
|
||||
break;
|
||||
|
||||
@@ -193,22 +193,15 @@ impl ClientHandler {
|
||||
|
||||
tokio::spawn(async move {
|
||||
while let Some(payload) = v_rx.recv().await {
|
||||
if payload.is_empty() {
|
||||
let close_frame =
|
||||
RawCastFrame::close(protocol, socket_id, dst_ip, dst_port);
|
||||
let _ = tx_engine_clone.send(close_frame).await;
|
||||
let data_frame = RawCastFrame::data(
|
||||
protocol,
|
||||
socket_id,
|
||||
dst_ip,
|
||||
dst_port,
|
||||
payload.to_vec(),
|
||||
);
|
||||
if tx_engine_clone.send(data_frame).await.is_err() {
|
||||
break;
|
||||
} else {
|
||||
let data_frame = RawCastFrame::data(
|
||||
protocol,
|
||||
socket_id,
|
||||
dst_ip,
|
||||
dst_port,
|
||||
payload.to_vec(),
|
||||
);
|
||||
if tx_engine_clone.send(data_frame).await.is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
muxer_clone.remove_stream(stream_id);
|
||||
|
||||
@@ -41,7 +41,8 @@ impl StreamHandler {
|
||||
let target_str = String::from_utf8_lossy(&payload).to_string();
|
||||
let muxer = self.muxer.clone();
|
||||
|
||||
let (v_tx, v_rx) = tokio::sync::mpsc::channel(NetworkConfig::global().stream_capacity);
|
||||
let (v_tx, v_rx) =
|
||||
tokio::sync::mpsc::channel(NetworkConfig::global().tcp_stream_capacity);
|
||||
muxer.register_stream(stream_id, v_tx);
|
||||
|
||||
tokio::spawn(async move {
|
||||
@@ -83,7 +84,8 @@ impl StreamHandler {
|
||||
let target_str = String::from_utf8_lossy(&payload).to_string();
|
||||
let muxer = self.muxer.clone();
|
||||
|
||||
let (v_tx, v_rx) = tokio::sync::mpsc::channel(NetworkConfig::global().stream_capacity);
|
||||
let (v_tx, v_rx) =
|
||||
tokio::sync::mpsc::channel(NetworkConfig::global().udp_stream_capacity);
|
||||
muxer.register_stream(stream_id, v_tx);
|
||||
|
||||
tokio::spawn(async move {
|
||||
@@ -128,7 +130,6 @@ impl StreamHandler {
|
||||
}
|
||||
|
||||
async fn on_close(&self, stream_id: u32) {
|
||||
self.muxer.dispatch_to_local(stream_id, Bytes::new()).await;
|
||||
self.muxer.remove_stream(stream_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user