MVP for VRPN header
This commit is contained in:
parent
2273a9824a
commit
b49fea5bc3
1 changed files with 22 additions and 8 deletions
|
@ -31,7 +31,6 @@ func _process(delta: float) -> void:
|
||||||
if new_status == _stream.STATUS_CONNECTED:
|
if new_status == _stream.STATUS_CONNECTED:
|
||||||
var available_bytes: int = _stream.get_available_bytes()
|
var available_bytes: int = _stream.get_available_bytes()
|
||||||
if available_bytes > 0:
|
if available_bytes > 0:
|
||||||
#print("available bytes: ", available_bytes)
|
|
||||||
var res = _stream.get_partial_data(available_bytes)
|
var res = _stream.get_partial_data(available_bytes)
|
||||||
if res[0] != OK:
|
if res[0] != OK:
|
||||||
emit_signal("error")
|
emit_signal("error")
|
||||||
|
@ -61,17 +60,32 @@ func _on_data(data : Array):
|
||||||
|
|
||||||
# Cookie Hack!
|
# Cookie Hack!
|
||||||
if as_cookie.begins_with("vrpn: ver."):
|
if as_cookie.begins_with("vrpn: ver."):
|
||||||
#print("VRPN magic cookie '{0}'".format([as_cookie]))
|
|
||||||
# kaboom we just send back the same cookie :)
|
# kaboom we just send back the same cookie :)
|
||||||
self.send(bytes)
|
self.send(bytes)
|
||||||
else:
|
else:
|
||||||
# non-cookie messages
|
# non-cookie messages
|
||||||
var header_bytes = bytes.slice(0,24)
|
var peer := StreamPeerBuffer.new()
|
||||||
var header_i32 = header_bytes.to_int32_array()
|
peer.data_array = bytes.slice(0,24)
|
||||||
#var vrpn_h = VRPN_Header.new(header_bytes)
|
peer.big_endian = true
|
||||||
#print(header_i32)
|
|
||||||
#print(header_bytes)
|
var length = peer.get_32() # length of message
|
||||||
print(bytes)
|
var time_sec = peer.get_32() # time sec
|
||||||
|
var time_msec = peer.get_32() # time millisec
|
||||||
|
var sender_id = peer.get_32() # sender id
|
||||||
|
var message_type = peer.get_32() # type of message (payload)
|
||||||
|
var sequence_num = peer.get_32() # inofficial
|
||||||
|
|
||||||
|
print("length %d" % length)
|
||||||
|
print("time_sec %d" % time_sec)
|
||||||
|
print("time_msec %d" % time_msec)
|
||||||
|
print("sender_id %d" % sender_id)
|
||||||
|
print("message_type %d" % message_type)
|
||||||
|
print("sequence_num %d" % sequence_num)
|
||||||
|
|
||||||
|
if message_type == 4:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_connected(s : StreamPeerTCP):
|
func _on_connected(s : StreamPeerTCP):
|
||||||
print("Connected to",s.get_connected_host()) # Replace with function body.
|
print("Connected to",s.get_connected_host()) # Replace with function body.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue