aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/client/client.rs4
-rw-r--r--core/src/constants.rs12
-rw-r--r--core/src/server/server.rs27
3 files changed, 18 insertions, 25 deletions
diff --git a/core/src/client/client.rs b/core/src/client/client.rs
index c11bb61..e861168 100644
--- a/core/src/client/client.rs
+++ b/core/src/client/client.rs
@@ -1,4 +1,4 @@
-use crate::constants::DEFAULT_PORT;
+use crate::constants::DEFAULT_PORT_UDP;
use crate::player::player_info::PlayerInfo;
use std::net::SocketAddr;
@@ -14,7 +14,7 @@ impl Default for PadClient {
fn default() -> Self {
PadClient {
player_info: PlayerInfo::default(),
- remote_addr: SocketAddr::from(([127, 0, 0, 1], DEFAULT_PORT)),
+ remote_addr: SocketAddr::from(([127, 0, 0, 1], DEFAULT_PORT_UDP)),
receive_skin_package: true
}
}
diff --git a/core/src/constants.rs b/core/src/constants.rs
index 6257c9d..ef5a3d6 100644
--- a/core/src/constants.rs
+++ b/core/src/constants.rs
@@ -1,8 +1,16 @@
use bincode::config;
use bincode::config::Configuration;
+// 默认 Hash 加盐
pub const SALT : &str = ":)";
-pub const DEFAULT_PORT : u16 = 8916;
+// 服务器默认端口
+pub const DEFAULT_PORT_UDP: u16 = 8916;
+pub const DEFAULT_PORT_TCP : u16 = 8916;
-pub const BINCODE_CONFIG : Configuration = config::standard(); \ No newline at end of file
+// 加密
+// BinCode 2.0 默认配置
+pub const BINCODE_CONFIG : Configuration = config::standard();
+
+// 加密失败时的值
+pub const BINCODE_CONVERT_FAILED : Vec<u8> = Vec::new(); \ No newline at end of file
diff --git a/core/src/server/server.rs b/core/src/server/server.rs
index c71892c..7f0eec3 100644
--- a/core/src/server/server.rs
+++ b/core/src/server/server.rs
@@ -1,4 +1,4 @@
-use crate::constants::DEFAULT_PORT;
+use crate::constants::{DEFAULT_PORT_TCP, DEFAULT_PORT_UDP};
use crate::server::server_event::PadServerEvent;
use std::net::{SocketAddr, UdpSocket};
@@ -6,7 +6,8 @@ use std::net::{SocketAddr, UdpSocket};
/// 监听服务器用于连接玩家设备,并接收玩家的按键输入
pub struct PadServer {
server_name: String,
- port: u16
+ port_request_server: u16,
+ port_io_server: u16
}
impl Default for PadServer {
@@ -16,7 +17,8 @@ impl Default for PadServer {
fn default() -> Self {
PadServer {
server_name: String::from("This Is No Pads"),
- port: DEFAULT_PORT
+ port_io_server: DEFAULT_PORT_UDP,
+ port_request_server: DEFAULT_PORT_TCP,
// TODO :: 补充布局文件
}
}
@@ -28,24 +30,7 @@ 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(_) => {}
- }
+
}
/// # 停止监听服务器