aboutsummaryrefslogtreecommitdiff
path: root/core/src/pads_server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/pads_server.rs')
-rw-r--r--core/src/pads_server.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/src/pads_server.rs b/core/src/pads_server.rs
index a9f3acb..d10a88b 100644
--- a/core/src/pads_server.rs
+++ b/core/src/pads_server.rs
@@ -1,4 +1,6 @@
+use std::net::{SocketAddr, UdpSocket};
use std::time::Duration;
+use bincode::Encode;
use crate::pads_player::{PlayerInfo, PlayerMessage};
/// # 监听服务器
@@ -27,7 +29,24 @@ impl PadServer {
/// self : 服务器
/// event : 事件
pub fn start_listening(&self, event : impl PadServerEvent) {
-
+ let socket_addr = SocketAddr::from(([127, 0, 0, 1], self.port));
+ match UdpSocket::bind(socket_addr) {
+ Ok(socket) => {
+ let mut buf = vec![0u8; 1024];
+
+ loop {
+ // 接收连接请求
+ match socket.recv_from(&mut buf) {
+ Ok((size, src)) => {
+
+ }
+ Err(_) => {}
+ }
+ }
+ }
+
+ Err(_) => {}
+ }
}
/// # 停止监听服务器