- add MeshPort peer-to-peer overlay networking SDK, C++ integration, and Python bindings - add item actions quick use/split/delete/lock overlay window (mt_item_actions) - add shop name range and NPC name visibility settings to system display options - support battlepass ticket activation and month validation in mt_battlepass - support boss tracking teleport destination button in mt_bosses - support asynchronous account registration cancellation and pending login cancellation - update AVA2 item conversion for attr lock scrolls and battlepass tickets - update .gitignore for local build outputs and caches
45 lines
1.4 KiB
Rust
45 lines
1.4 KiB
Rust
//! Run on the game server; TCP/UDP echo is separate from the actual game service.
|
|
use anyhow::Result;
|
|
use tokio::{
|
|
io::{AsyncReadExt, AsyncWriteExt},
|
|
net::{TcpListener, UdpSocket},
|
|
};
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let addr = std::env::args()
|
|
.nth(1)
|
|
.unwrap_or_else(|| "127.0.0.1:7007".into());
|
|
let tcp = TcpListener::bind(&addr).await?;
|
|
let udp = UdpSocket::bind(&addr).await?;
|
|
println!("MeshPort TCP/UDP echo listening on {addr}");
|
|
let tcp_task = async {
|
|
loop {
|
|
let (mut socket, _) = tcp.accept().await?;
|
|
tokio::spawn(async move {
|
|
let mut buffer = [0; 16384];
|
|
loop {
|
|
let n = socket.read(&mut buffer).await?;
|
|
if n == 0 {
|
|
break;
|
|
}
|
|
socket.write_all(&buffer[..n]).await?;
|
|
}
|
|
Ok::<_, std::io::Error>(())
|
|
});
|
|
}
|
|
#[allow(unreachable_code)]
|
|
Ok::<(), std::io::Error>(())
|
|
};
|
|
let udp_task = async {
|
|
let mut buffer = [0; 65535];
|
|
loop {
|
|
let (n, peer) = udp.recv_from(&mut buffer).await?;
|
|
udp.send_to(&buffer[..n], peer).await?;
|
|
}
|
|
#[allow(unreachable_code)]
|
|
Ok::<(), std::io::Error>(())
|
|
};
|
|
tokio::try_join!(tcp_task, udp_task)?;
|
|
Ok(())
|
|
}
|