THIS WORKS BUT IS UGLY AND I DON'T CARE
This commit is contained in:
parent
b03514b8bd
commit
36b5063637
2 changed files with 7 additions and 5 deletions
|
@ -6,7 +6,7 @@ mod systems;
|
|||
|
||||
use crate::config::Settings;
|
||||
use crate::game::Game;
|
||||
use crate::network::{listen, NetworkManager};
|
||||
use crate::network::listen;
|
||||
use async_std::sync::Arc;
|
||||
use async_std::{sync::channel, task};
|
||||
use env_logger::Env;
|
||||
|
|
|
@ -34,17 +34,19 @@ impl NetworkManager {
|
|||
self.connections.insert(conn.conn_id, conn);
|
||||
}
|
||||
|
||||
async fn send(&self, message: NetworkMessage) {
|
||||
async fn send(&mut self, message: NetworkMessage) {
|
||||
let conn = self
|
||||
.connections
|
||||
.get(&message.conn_id)
|
||||
.get_mut(&message.conn_id)
|
||||
.expect("cant send message to an unregistered connection");
|
||||
conn.stream.send(message.data).await;
|
||||
conn.stream
|
||||
.send(message.data)
|
||||
.await
|
||||
.expect("could not send message to connection");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn listen(
|
||||
net: Arc<NetworkManager>,
|
||||
bind: String,
|
||||
incoming: Sender<NetworkMessage>,
|
||||
outgoing: Receiver<NetworkMessage>,
|
||||
|
|
Loading…
Reference in a new issue