Skip to content

Commit

Permalink
Use UPnP
Browse files Browse the repository at this point in the history
  • Loading branch information
Janorico committed Jun 5, 2023
1 parent 3340379 commit f0e0f75
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/Network.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ func _ready():


func init_server(info: Dictionary):
# Setup UPNP
var upnp = UPNP.new()
var err = upnp.discover()
if err == OK:
if upnp.get_gateway() and upnp.get_gateway().is_valid_gateway():
upnp.get_gateway().add_port_mapping(PORT, PORT, "VoxelFun Multiplayer", "UDP")
upnp.get_gateway().add_port_mapping(PORT, PORT, "VoxelFun Multiplayer", "TCP")
else:
push_error("UPNP error: %d" % err)
# Setup multiplayer
my_player = info
var peer = NetworkedMultiplayerENet.new()
peer.create_server(PORT, MAX_CLIENTS)
Expand Down

0 comments on commit f0e0f75

Please sign in to comment.