Servers from games based on Valve's Source Multiplayer Networking send packets in a high frequency to update the game world.
I need a WebSocket server library. I saw tokio-tungstenite, but it says it's not the most performant library for WebSockets. Any other recommendation then?
Tokio-tungstenite's documentation mentions fastwebsockets as a performant alternative. Have you checked that one yet?
On the other hand, if you are gonna use socket.io on the client side I wouldn't be bothered about tokio-tungstenite not being the most performant server, to be honest...
I've thought the same, so I decided to try compiling a basic handshake from tokio-tungstenite.
It looks to work after a cargo run, but the problem is that rust-analyzer is outputting {unknown} for everything coming from the websocket_stream.split() call. split() itself doesn't even appear...
let (outgoing, incoming) = websocket_stream.split();
let broadcast_incoming = incoming.try_for_each(|msg| {
// Received a message from `address`
let peers = peer_map.lock().unwrap();
// We want to broadcast the message to everyone except ourselves.
let broadcast_recipients =
peers.iter().filter(|(peer_address, _)| peer_address != &&address).map(|(_, websocket_sink)| websocket_sink);
for recipient in broadcast_recipients {
recipient.unbounded_send(msg.clone()).unwrap();
}
future::ok(())
});
I had to restart the IDE and now the types show up. Strange...