remove rpc, cli start
This commit is contained in:
@ -4,4 +4,4 @@ mod client;
|
||||
|
||||
mod socket;
|
||||
|
||||
pub use socket::process_mc_socket;
|
||||
pub use socket::mc_socket_listen;
|
||||
|
||||
@ -3,7 +3,25 @@ use tokio::net::TcpStream;
|
||||
|
||||
use crate::DbPool;
|
||||
|
||||
pub async fn process_mc_socket(stream: TcpStream, pool: DbPool) -> Result<(), String> {
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
use std::io;
|
||||
|
||||
pub async fn mc_socket_listen(pool: DbPool) -> io::Result<()> {
|
||||
let mc_listener = TcpListener::bind("0.0.0.0:25565").await?;
|
||||
loop {
|
||||
if let Ok((socket, _)) = mc_listener.accept().await {
|
||||
let cloned = pool.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = process_mc_socket(socket, cloned).await {
|
||||
eprintln!("mc error: {:?}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn process_mc_socket(stream: TcpStream, pool: DbPool) -> Result<(), String> {
|
||||
println!("new client {:?}", stream);
|
||||
|
||||
let mut client = Client::create(stream, pool);
|
||||
|
||||
Reference in New Issue
Block a user