mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-22 07:27:44 +00:00
Specify a connection type when sending packets
This commit is contained in:
parent
f886fbfe4b
commit
1f2283af14
5 changed files with 18 additions and 15 deletions
|
@ -5,6 +5,7 @@ use kawari::lobby::ipc::{
|
||||||
ServerLobbyIpcSegment, ServerLobbyIpcType,
|
ServerLobbyIpcSegment, ServerLobbyIpcType,
|
||||||
};
|
};
|
||||||
use kawari::oodle::OodleNetwork;
|
use kawari::oodle::OodleNetwork;
|
||||||
|
use kawari::packet::ConnectionType;
|
||||||
use kawari::packet::{PacketSegment, PacketState, SegmentType, send_keep_alive};
|
use kawari::packet::{PacketSegment, PacketState, SegmentType, send_keep_alive};
|
||||||
use kawari::{CONTENT_ID, WORLD_NAME};
|
use kawari::{CONTENT_ID, WORLD_NAME};
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
|
@ -214,6 +215,7 @@ async fn main() {
|
||||||
send_keep_alive::<ServerLobbyIpcSegment>(
|
send_keep_alive::<ServerLobbyIpcSegment>(
|
||||||
&mut connection.socket,
|
&mut connection.socket,
|
||||||
&mut connection.state,
|
&mut connection.state,
|
||||||
|
ConnectionType::Lobby,
|
||||||
*id,
|
*id,
|
||||||
*timestamp,
|
*timestamp,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use kawari::oodle::OodleNetwork;
|
use kawari::oodle::OodleNetwork;
|
||||||
use kawari::packet::{PacketSegment, PacketState, SegmentType, send_keep_alive};
|
use kawari::packet::{ConnectionType, PacketSegment, PacketState, SegmentType, send_keep_alive};
|
||||||
use kawari::world::ipc::{
|
use kawari::world::ipc::{
|
||||||
ClientZoneIpcData, GameMasterCommandType, ServerZoneIpcData, ServerZoneIpcSegment,
|
ClientZoneIpcData, GameMasterCommandType, ServerZoneIpcData, ServerZoneIpcSegment,
|
||||||
ServerZoneIpcType, SocialListRequestType,
|
ServerZoneIpcType, SocialListRequestType,
|
||||||
|
@ -594,6 +594,7 @@ async fn main() {
|
||||||
send_keep_alive::<ServerZoneIpcSegment>(
|
send_keep_alive::<ServerZoneIpcSegment>(
|
||||||
&mut connection.socket,
|
&mut connection.socket,
|
||||||
&mut connection.state,
|
&mut connection.state,
|
||||||
|
ConnectionType::Zone,
|
||||||
*id,
|
*id,
|
||||||
*timestamp,
|
*timestamp,
|
||||||
)
|
)
|
||||||
|
|
|
@ -42,9 +42,10 @@ impl LobbyConnection {
|
||||||
pub async fn send_segment(&mut self, segment: PacketSegment<ServerLobbyIpcSegment>) {
|
pub async fn send_segment(&mut self, segment: PacketSegment<ServerLobbyIpcSegment>) {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
&[segment],
|
|
||||||
&mut self.state,
|
&mut self.state,
|
||||||
|
ConnectionType::Lobby,
|
||||||
CompressionType::Uncompressed,
|
CompressionType::Uncompressed,
|
||||||
|
&[segment],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -169,9 +170,10 @@ impl LobbyConnection {
|
||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
&packets,
|
|
||||||
&mut self.state,
|
&mut self.state,
|
||||||
|
ConnectionType::Lobby,
|
||||||
CompressionType::Uncompressed,
|
CompressionType::Uncompressed,
|
||||||
|
&packets,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -133,9 +133,10 @@ fn dump(msg: &str, data: &[u8]) {
|
||||||
|
|
||||||
pub async fn send_packet<T: ReadWriteIpcSegment>(
|
pub async fn send_packet<T: ReadWriteIpcSegment>(
|
||||||
socket: &mut TcpStream,
|
socket: &mut TcpStream,
|
||||||
segments: &[PacketSegment<T>],
|
|
||||||
state: &mut PacketState,
|
state: &mut PacketState,
|
||||||
|
connection_type: ConnectionType,
|
||||||
compression_type: CompressionType,
|
compression_type: CompressionType,
|
||||||
|
segments: &[PacketSegment<T>],
|
||||||
) {
|
) {
|
||||||
let (data, uncompressed_size) = compress(state, &compression_type, segments);
|
let (data, uncompressed_size) = compress(state, &compression_type, segments);
|
||||||
let size = std::mem::size_of::<PacketHeader>() + data.len();
|
let size = std::mem::size_of::<PacketHeader>() + data.len();
|
||||||
|
@ -145,7 +146,7 @@ pub async fn send_packet<T: ReadWriteIpcSegment>(
|
||||||
unk2: 0x75C4997B4D642A7F, // wtf? x2
|
unk2: 0x75C4997B4D642A7F, // wtf? x2
|
||||||
timestamp: timestamp_msecs(),
|
timestamp: timestamp_msecs(),
|
||||||
size: size as u32,
|
size: size as u32,
|
||||||
connection_type: ConnectionType::Lobby,
|
connection_type,
|
||||||
segment_count: segments.len() as u16,
|
segment_count: segments.len() as u16,
|
||||||
unk3: 0,
|
unk3: 0,
|
||||||
compression_type,
|
compression_type,
|
||||||
|
@ -202,6 +203,7 @@ pub async fn parse_packet<T: ReadWriteIpcSegment>(
|
||||||
pub async fn send_keep_alive<T: ReadWriteIpcSegment>(
|
pub async fn send_keep_alive<T: ReadWriteIpcSegment>(
|
||||||
socket: &mut TcpStream,
|
socket: &mut TcpStream,
|
||||||
state: &mut PacketState,
|
state: &mut PacketState,
|
||||||
|
connection_type: ConnectionType,
|
||||||
id: u32,
|
id: u32,
|
||||||
timestamp: u32,
|
timestamp: u32,
|
||||||
) {
|
) {
|
||||||
|
@ -212,9 +214,10 @@ pub async fn send_keep_alive<T: ReadWriteIpcSegment>(
|
||||||
};
|
};
|
||||||
send_packet(
|
send_packet(
|
||||||
socket,
|
socket,
|
||||||
&[response_packet],
|
|
||||||
state,
|
state,
|
||||||
|
connection_type,
|
||||||
CompressionType::Uncompressed,
|
CompressionType::Uncompressed,
|
||||||
|
&[response_packet],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,10 @@ impl ZoneConnection {
|
||||||
pub async fn send_segment(&mut self, segment: PacketSegment<ServerZoneIpcSegment>) {
|
pub async fn send_segment(&mut self, segment: PacketSegment<ServerZoneIpcSegment>) {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
&[segment],
|
|
||||||
&mut self.state,
|
&mut self.state,
|
||||||
|
ConnectionType::Zone,
|
||||||
CompressionType::Oodle,
|
CompressionType::Oodle,
|
||||||
|
&[segment],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -59,17 +60,11 @@ impl ZoneConnection {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let response_packet = PacketSegment {
|
self.send_segment(PacketSegment {
|
||||||
source_actor: self.player_id,
|
source_actor: self.player_id,
|
||||||
target_actor: self.player_id,
|
target_actor: self.player_id,
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
};
|
})
|
||||||
send_packet(
|
|
||||||
&mut self.socket,
|
|
||||||
&[response_packet],
|
|
||||||
&mut self.state,
|
|
||||||
CompressionType::Oodle,
|
|
||||||
)
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue