HBSteamNetworking
Inherits: RefCounted < Object
Class to interact with Steam Networking.
Methods
void |
allow_p2p_packet_relay ( bool allow_packet_relay ) |
close_p2p_session_with_user ( HBSteamFriend user ) |
|
is_p2p_packet_available ( int channel=0 ) |
|
read_p2p_packet ( int channel=0 ) |
|
send_p2p_packet ( HBSteamFriend target_user, PackedByteArray data, P2PSend send_type=2, int channel=0 ) |
Signals
p2p_connection_failed ( HBSteamFriend user, int connection_error )
Emitted when a connection has failed, returns a P2PSessionError.
p2p_session_requested ( HBSteamFriend user )
Emitted when a user wants to establish a P2P connection with us.
You can accept this connection by calling accept_p2p_session_with_user.
Method Descriptions
bool accept_p2p_session_with_user ( HBSteamFriend user )
This allows the game to specify accept an incoming packet. This needs to be called before a real connection is established to a remote host, the game will get a chance to say whether or not the remote user is allowed to talk to them.
void allow_p2p_packet_relay ( bool allow_packet_relay )
Allow or disallow P2P connections to fall back to being relayed through the Steam servers if a direct connection or NAT-traversal cannot be established.
This only applies to connections created after setting this value, or to existing connections that need to automatically reconnect after this value is set.
P2P packet relay is allowed by default.
bool close_p2p_session_with_user ( HBSteamFriend user )
This should be called when you’re done communicating with a user, as this will free up all of the resources allocated for the connection under-the-hood.
bool is_p2p_packet_available ( int channel=0 )
Returns true
if there’s a new packet available, you can retrieve it with read_p2p_packet.
SteamP2PPacket read_p2p_packet ( int channel=0 )
Returns a P2P packet, make sure you’ve checked there’s any packets to process with is_p2p_packet_available first.
bool send_p2p_packet ( HBSteamFriend target_user, PackedByteArray data, P2PSend send_type=2, int channel=0 )
Sends a P2P packet through the given channel to the given user.