Skip to content
Snippets Groups Projects
Commit 00d851a4 authored by Florent Berthaut's avatar Florent Berthaut
Browse files

Fixed network on godot4

parent 1d96539d
Branches
No related tags found
No related merge requests found
......@@ -107,6 +107,7 @@ IvmiScene provides a number of settings to help you design immersive instruments
* XR Mode
* ...
### IVMI-node
IVMI-node are the main components of any IVMI instruments. IVMI-node contains IVMI-properties. By inheriting IVMI-node.gd you are able to define a specific behavior/feedback for each IVMI-property change that occur within the node. You can for example write a code that change the size of the node's mesh when the node is selected.
......@@ -115,18 +116,21 @@ IVMI-node are the main components of any IVMI instruments. IVMI-node contains IV
extends IvmiNode
func _ready():
#Optionally define a node type
# Call default IvmiNode constructor
super._ready()
# Optionally define a node type
_set_ivmi_type("my_node")
#Add custom properties with array of values
# Add custom properties with array of values
_add_property("selected", [0])
func set_property(prop, vals) :
#call default properties handling
super.set_property(prop, vals)
func _set_property(prop, vals) :
# Call default properties handling
super._set_property(prop, vals)
#handle custom properties
# Handle custom properties
if prop == "selected":
if vals[0]:
get_node("MeshInstance").scale.x = 3
......
......@@ -278,11 +278,13 @@ func _on_found_server(server_ip, port) :
#_network_client.connect_to_server(server_ip, port)
pass
NetProto.Enet :
print("IVMI : Connecting to server ", server_ip, " ", port)
var peer = ENetMultiplayerPeer.new()
peer.create_client(server_ip, port)
multiplayer.multiplayer_peer = peer
multiplayer.connected_to_server.connect(_on_network_ready)
if !_is_connected or _server_ip!=server_ip :
print("IVMI : Connecting to server ", server_ip, " ", port)
var peer = ENetMultiplayerPeer.new()
_server_ip=server_ip
peer.create_client(server_ip, port)
multiplayer.multiplayer_peer = peer
multiplayer.connected_to_server.connect(_on_network_ready)
func _on_timeout() :
......
......@@ -25,8 +25,11 @@ func start() :
print("IVMI : Starting Network Discovery")
var mcadd = "239.215.216.217"
var mcprt = 8173
if _is_server :
_osc_discov.set_output(mcadd, mcprt)
else :
_osc_discov.set_input_port(mcprt)
_osc_discov.set_multicast(mcadd)
_osc_discov.set_output(mcadd, mcprt)
#retrieve local address
_local_addr = "127.0.0.1"
......@@ -39,7 +42,7 @@ func _process(delta) :
if _is_server :
_ping_time+=delta
if _ping_time>5.0 :
_osc_discov.send_msg("/ivmi/hello_from_server","s",[_local_addr, _port])
_osc_discov.send_msg("/ivmi/hello_from_server","sf",[_local_addr, _port])
_ping_time=0
while _osc_discov.has_msg() :
var msg = _osc_discov.get_msg()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment