@@ -41,9 +41,19 @@ pub mod networking {
4141 steam_id64 : BigInt ,
4242 send_type : SendType ,
4343 data : Buffer ,
44+ ) -> Result < bool , Error > {
45+ self :: send_p2p_packet_on_channel ( steam_id64, send_type, data, 0 )
46+ }
47+
48+ #[ napi]
49+ pub fn send_p2p_packet_on_channel (
50+ steam_id64 : BigInt ,
51+ send_type : SendType ,
52+ data : Buffer ,
53+ channel : i32 ,
4454 ) -> Result < bool , Error > {
4555 let client = crate :: client:: get_client ( ) ;
46- let result = client. networking ( ) . send_p2p_packet (
56+ let result = client. networking ( ) . send_p2p_packet_on_channel (
4757 SteamId :: from_raw ( steam_id64. get_u64 ( ) . 1 ) ,
4858 match send_type {
4959 SendType :: Unreliable => steamworks:: SendType :: Unreliable ,
@@ -52,27 +62,38 @@ pub mod networking {
5262 SendType :: ReliableWithBuffering => steamworks:: SendType :: ReliableWithBuffering ,
5363 } ,
5464 & data,
65+ channel
5566 ) ;
5667 Ok ( result)
5768 }
5869
5970 #[ napi]
6071 pub fn is_p2p_packet_available ( ) -> i32 {
72+ self :: is_p2p_packet_available_on_channel ( 0 )
73+ }
74+
75+ #[ napi]
76+ pub fn is_p2p_packet_available_on_channel ( channel : i32 ) -> i32 {
6177 let client = crate :: client:: get_client ( ) ;
6278 client
6379 . networking ( )
64- . is_p2p_packet_available ( )
80+ . is_p2p_packet_available_on_channel ( channel )
6581 . unwrap_or_default ( ) as i32
6682 }
6783
6884 #[ napi]
6985 pub fn read_p2p_packet ( size : i32 ) -> Result < P2PPacket , Error > {
86+ self :: read_p2p_packet_from_channel ( size, 0 )
87+ }
88+
89+ #[ napi]
90+ pub fn read_p2p_packet_from_channel ( size : i32 , channel : i32 ) -> Result < P2PPacket , Error > {
7091 let client = crate :: client:: get_client ( ) ;
7192 let mut buffer = vec ! [ 0 ; size as usize ] ;
7293
7394 client
7495 . networking ( )
75- . read_p2p_packet ( & mut buffer)
96+ . read_p2p_packet_from_channel ( & mut buffer, channel )
7697 . map ( |( steam_id, read_size) | P2PPacket {
7798 data : buffer. into ( ) ,
7899 size : read_size as i32 ,
0 commit comments