WIP
This commit is contained in:
parent
8cb2c0c1be
commit
127eef5a8b
2 changed files with 3498 additions and 3 deletions
23
uvrpn.gd
23
uvrpn.gd
|
@ -3,11 +3,17 @@ extends Node
|
||||||
@export var url : String = "localhost"
|
@export var url : String = "localhost"
|
||||||
@export var port : int = 3883
|
@export var port : int = 3883
|
||||||
|
|
||||||
var server : UDPServer = UDPServer.new()
|
var server : UDPServer = null
|
||||||
|
var socket : StreamPeerTCP = StreamPeerTCP.new()
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
server.listen(3883)
|
if StreamPeerTCP.STATUS_NONE == socket.get_status():
|
||||||
|
if socket.connect_to_host("localhost",3883) == OK:
|
||||||
|
send_data(socket,"localhost".to_utf8_buffer())
|
||||||
|
server = UDPServer.new()
|
||||||
|
server.listen(3883)
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
server.poll()
|
server.poll()
|
||||||
if server.is_connection_available():
|
if server.is_connection_available():
|
||||||
|
@ -17,3 +23,14 @@ func _process(delta: float) -> void:
|
||||||
print("Received data: %s" % [packet.get_string_from_utf8()])
|
print("Received data: %s" % [packet.get_string_from_utf8()])
|
||||||
# Reply so it knows we received the message.
|
# Reply so it knows we received the message.
|
||||||
peer.put_packet(packet)
|
peer.put_packet(packet)
|
||||||
|
|
||||||
|
|
||||||
|
static func send_data(socket : StreamPeerTCP, data: PackedByteArray) -> bool:
|
||||||
|
if socket.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||||
|
print("Error: Stream is not currently connected.")
|
||||||
|
return false
|
||||||
|
var error: int = socket.put_data(data)
|
||||||
|
if error != OK:
|
||||||
|
print("Error writing to stream: ", error)
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
3478
vrpn.test.cfg
Normal file
3478
vrpn.test.cfg
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue