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