Commit ca9735cc1a

ca9735cc1aade554a08ef4efca00e6cd9c0273bb

parent: 48432107f4

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-03-01 18:38 UTC

server: Don't pass a response receiver sender to the send method.

Layout: unified · split

src/server.rs +5 −3
@@ -334,13 +334,13 @@ impl MatrixServer {
334334 };
335335
336336 let (tx, rx) = async_channel(1000);
337 runtime.spawn(MatrixServer::sync_loop(client.clone(), tx.clone()));
337 runtime.spawn(MatrixServer::sync_loop(client.clone(), tx));
338338 let response_receiver = Weechat::spawn(
339339 MatrixServer::response_receiver(rx, Rc::downgrade(&self.inner)),
340340 );
341341
342342 let (client_sender, client_receiver) = async_channel(10);
343 runtime.spawn(MatrixServer::send_loop(client, client_receiver, tx));
343 runtime.spawn(MatrixServer::send_loop(client, client_receiver));
344344
345345 let mut connected_state = server.connected_state.borrow_mut();
346346
@@ -485,7 +485,6 @@ impl MatrixServer {
485485 pub async fn send_loop(
486486 mut client: AsyncClient,
487487 channel: Receiver<ServerMessage>,
488 sender: Sender<Result<ThreadMessage, String>>,
489488 ) {
490489 while let Some(message) = channel.recv().await {
491490 match message {
@@ -498,6 +497,9 @@ impl MatrixServer {
498497 relates_to: None,
499498 });
500499
500 // TODO awaiting here means we can only send one message
501 // at a time, we need to spawn a task here and return a
502 // oneshot channel that the caller can await.
501503 let ret = client.room_send(&room_id, content).await;
502504
503505 match ret {