DTLSServer
Helper class to implement a DTLS server.
This class is used to store the state of a DTLS server. Upon it converts connected PacketPeerUDP to accepting them via take_connection as DTLS clients. Under the hood, this class is used to store the DTLS state and cookies of the server. The reason of why the state and cookies are needed is outside of the scope of this documentation.
extends Node
var dtls := PacketPeerDTLS.new()
var connected = false
func _ready():
dtls.connect_to_peer(udp, false) # Use true in production for certificate validation!
func _process(delta):
if dtls.get_status() == PacketPeerDTLS.STATUS_CONNECTED:
if !connected:
# Try to contact server
while dtls.get_available_packet_count() > 0:
print("Connected: %s" % dtls.get_packet().get_string_from_utf8())
connected = true
Setup the DTLS server to use the given private_key
and provide the given certificate
to clients. You can pass the optional chain
parameter to provide additional CA chain information along with the certificate.
- take_connection ( PacketPeerUDP udp_peer )
Note: You must check that the state of the return PacketPeerUDP is , as it is normal that 50% of the new connections will be invalid due to cookie exchange.