@@ -41,9 +41,19 @@ pub mod networking {
41
41
steam_id64 : BigInt ,
42
42
send_type : SendType ,
43
43
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 ,
44
54
) -> Result < bool , Error > {
45
55
let client = crate :: client:: get_client ( ) ;
46
- let result = client. networking ( ) . send_p2p_packet (
56
+ let result = client. networking ( ) . send_p2p_packet_on_channel (
47
57
SteamId :: from_raw ( steam_id64. get_u64 ( ) . 1 ) ,
48
58
match send_type {
49
59
SendType :: Unreliable => steamworks:: SendType :: Unreliable ,
@@ -52,27 +62,38 @@ pub mod networking {
52
62
SendType :: ReliableWithBuffering => steamworks:: SendType :: ReliableWithBuffering ,
53
63
} ,
54
64
& data,
65
+ channel
55
66
) ;
56
67
Ok ( result)
57
68
}
58
69
59
70
#[ napi]
60
71
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 {
61
77
let client = crate :: client:: get_client ( ) ;
62
78
client
63
79
. networking ( )
64
- . is_p2p_packet_available ( )
80
+ . is_p2p_packet_available_on_channel ( channel )
65
81
. unwrap_or_default ( ) as i32
66
82
}
67
83
68
84
#[ napi]
69
85
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 > {
70
91
let client = crate :: client:: get_client ( ) ;
71
92
let mut buffer = vec ! [ 0 ; size as usize ] ;
72
93
73
94
client
74
95
. networking ( )
75
- . read_p2p_packet ( & mut buffer)
96
+ . read_p2p_packet_from_channel ( & mut buffer, channel )
76
97
. map ( |( steam_id, read_size) | P2PPacket {
77
98
data : buffer. into ( ) ,
78
99
size : read_size as i32 ,
0 commit comments