Skip to content

Commit 1c52793

Browse files
committed
Fix remaining issues
1 parent 5fb709a commit 1c52793

File tree

7 files changed

+30
-27
lines changed

7 files changed

+30
-27
lines changed

addons/godot-firebase/Utilies.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ extends Node
22
class_name Utilities
33

44
static func get_json_data(value):
5+
if value is PackedByteArray:
6+
value = value.get_string_from_utf8()
57
var json = JSON.new()
68
var json_parse_result = json.parse(value)
79
if json_parse_result == OK:

addons/godot-firebase/auth/auth.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func manual_token_refresh(auth_data):
403403
# This function is called whenever there is an authentication request to Firebase
404404
# On an error, this function with emit the signal 'login_failed' and print the error to the console
405405
func _on_FirebaseAuth_request_completed(result : int, response_code : int, headers : PackedStringArray, body : PackedByteArray) -> void:
406-
var json = Utilities.get_json_data(body)
406+
var json = Utilities.get_json_data(body.get_string_from_utf8())
407407
is_busy = false
408408
var res
409409
if response_code == 0:
@@ -467,7 +467,6 @@ func save_auth(auth : Dictionary) -> void:
467467
Firebase._printerr("Error Opening File. Error Code: " + str(FileAccess.get_open_error()))
468468
else:
469469
encrypted_file.store_line(JSON.stringify(auth))
470-
encrypted_file.close()
471470

472471

473472
# Function used to load the auth data file that has been stored locally

addons/godot-firebase/database/database.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func _on_FirebaseAuth_logout() -> void:
4242
func get_database_reference(path : String, filter : Dictionary = {}) -> FirebaseDatabaseReference:
4343
var firebase_reference : FirebaseDatabaseReference = FirebaseDatabaseReference.new()
4444
var pusher : HTTPRequest = HTTPRequest.new()
45+
pusher.use_threads = true
4546
var listener : Node = Node.new()
4647
listener.set_script(load("res://addons/http-sse-client/HTTPSSEClient.gd"))
4748
var store : FirebaseDatabaseStore = FirebaseDatabaseStore.new()
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
[gd_scene load_steps=8 format=2]
1+
[gd_scene load_steps=8 format=3 uid="uid://cvb26atjckwlq"]
22

3-
[ext_resource path="res://addons/godot-firebase/database/database.gd" type="Script" id=1]
4-
[ext_resource path="res://addons/godot-firebase/firestore/firestore.gd" type="Script" id=2]
5-
[ext_resource path="res://addons/godot-firebase/firebase/firebase.gd" type="Script" id=3]
6-
[ext_resource path="res://addons/godot-firebase/auth/auth.gd" type="Script" id=4]
7-
[ext_resource path="res://addons/godot-firebase/storage/storage.gd" type="Script" id=5]
8-
[ext_resource path="res://addons/godot-firebase/dynamiclinks/dynamiclinks.gd" type="Script" id=6]
9-
[ext_resource path="res://addons/godot-firebase/functions/functions.gd" type="Script" id=7]
3+
[ext_resource type="Script" path="res://addons/godot-firebase/database/database.gd" id="1"]
4+
[ext_resource type="Script" path="res://addons/godot-firebase/firestore/firestore.gd" id="2"]
5+
[ext_resource type="Script" path="res://addons/godot-firebase/firebase/firebase.gd" id="3"]
6+
[ext_resource type="Script" path="res://addons/godot-firebase/auth/auth.gd" id="4"]
7+
[ext_resource type="Script" path="res://addons/godot-firebase/storage/storage.gd" id="5"]
8+
[ext_resource type="Script" path="res://addons/godot-firebase/dynamiclinks/dynamiclinks.gd" id="6"]
9+
[ext_resource type="Script" path="res://addons/godot-firebase/functions/functions.gd" id="7"]
1010

1111
[node name="Firebase" type="Node"]
12-
process_mode = 2
13-
script = ExtResource( 3 )
12+
script = ExtResource("3")
1413

1514
[node name="Auth" type="HTTPRequest" parent="."]
16-
script = ExtResource( 4 )
15+
max_redirects = 12
16+
timeout = 10.0
17+
script = ExtResource("4")
1718

1819
[node name="Firestore" type="Node" parent="."]
19-
script = ExtResource( 2 )
20+
script = ExtResource("2")
2021

2122
[node name="Database" type="Node" parent="."]
22-
script = ExtResource( 1 )
23+
script = ExtResource("1")
2324

2425
[node name="Storage" type="Node" parent="."]
25-
script = ExtResource( 5 )
26+
script = ExtResource("5")
2627

2728
[node name="DynamicLinks" type="Node" parent="."]
28-
script = ExtResource( 6 )
29+
script = ExtResource("6")
2930

3031
[node name="Functions" type="Node" parent="."]
31-
script = ExtResource( 7 )
32+
script = ExtResource("7")

addons/godot-firebase/storage/storage.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func _download(ref : StorageReference, meta_only : bool, url_only : bool) -> Sto
192192

193193
var data = await info_task.task_finished
194194
if info_task.result == OK:
195-
task._url += data.downloadTokens # I don't see how this will ever work, but who knows; pretty sure it doesn't, which means in theory it should be running the else every single time; data is a PackedByteArray, not sure what the original code was smoking
195+
task._url += info_task.data.downloadTokens
196196
else:
197197
task.data = info_task.data
198198
task.response_headers = info_task.response_headers
@@ -306,7 +306,7 @@ func _finish_request(result : int) -> void:
306306
next_task = _pending_tasks.pop_front()
307307

308308
task.finished = true
309-
task.task_finished.emit()
309+
task.task_finished.emit(task.data) # I believe this parameter has been missing all along, but not sure. Caused weird results at times with a yield/await returning null, but the task containing data.
310310
if typeof(task.data) == TYPE_DICTIONARY and task.data.has("error"):
311311
task_failed.emit(task.result, task.response_code, task.data)
312312
else:

addons/godot-firebase/storage/storage_reference.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ func put_string(data : String, metadata := {}) -> StorageTask:
104104
func put_file(file_path : String, metadata := {}) -> StorageTask:
105105
var file := FileAccess.open(file_path, FileAccess.READ)
106106
var data := file.get_buffer(file.get_length())
107-
file.close()
108107

109108
if "Content-Type" in metadata:
110109
metadata["Content-Type"] = MIME_TYPES.get(file_path.get_extension(), DEFAULT_MIME_TYPE)

addons/http-sse-client/HTTPSSEClient.gd

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var is_requested = false
2323
var response_body = PackedByteArray()
2424

2525
func connect_to_host(domain : String, url_after_domain : String, port : int = -1, trusted_chain : X509Certificate = null, common_name_override : String = ""):
26+
process_mode = Node.PROCESS_MODE_INHERIT
2627
self.domain = domain
2728
self.url_after_domain = url_after_domain
2829
self.port = port
@@ -103,7 +104,7 @@ func _process(delta):
103104
if response_body.size() > 0:
104105
_parse_response_body(headers)
105106

106-
func get_event_data(body : String) -> Dictionary:
107+
func get_event_data(body : String):
107108
var result = {}
108109
var event_idx = body.find(event_tag)
109110
if event_idx == -1:
@@ -113,11 +114,11 @@ func get_event_data(body : String) -> Dictionary:
113114
var data_idx = body.find(data_tag, event_idx + event_tag.length())
114115
assert(data_idx != -1)
115116
var event = body.substr(event_idx, data_idx)
116-
event = event.replace(event_tag, "").strip_edges()
117-
assert(event)
118-
assert(event.length() > 0)
119-
result["event"] = event
120-
var data = body.right(data_idx + data_tag.length()).strip_edges()
117+
var event_value = event.replace(event_tag, "").strip_edges()
118+
assert(event_value)
119+
assert(event_value.length() > 0)
120+
result["event"] = event_value
121+
var data = body.right(body.length() - (data_idx + data_tag.length())).strip_edges()
121122
assert(data)
122123
assert(data.length() > 0)
123124
result["data"] = data

0 commit comments

Comments
 (0)