OverviewFilesCommitsIssuesDocsReleasesPeers

hypergodot commits / 59a5aed

Restructure how requests work
59a5aedfb147fcdeac928e52d346ca88d56ef3c1
by mauve <ranger@mauve.moe> · 2021-06-08T22:21:18.000Z

Changed files (16) +367 -107

.godot/editor/GatewayRequest.gd-folding-061d6dac82635533681dbfaaae71c270.cfg +3 -0
……@@ -0,0 +1,3 @@
1[folding]
2
3sections_unfolded=PackedStringArray( )
.godot/editor/HyperLoad.tscn-editstate-bf53ee672d2552cd7d04dd13139dfd05.cfg +173 -0
……@@ -0,0 +1,173 @@
1[editor_states]
2
3Anim={
4"visible": false
5}
62D={
7"grid_offset": Vector2( 0, 0 ),
8"grid_snap_active": false,
9"grid_step": Vector2( 8, 8 ),
10"ofs": Vector2( -374.47, -437.365 ),
11"primary_grid_steps": 8,
12"show_edit_locks": true,
13"show_grid": false,
14"show_guides": true,
15"show_helpers": false,
16"show_origin": true,
17"show_rulers": true,
18"show_transformation_gizmos": true,
19"show_viewport": true,
20"show_zoom_control": true,
21"skeleton_show_bones": true,
22"smart_snap_active": false,
23"snap_guides": true,
24"snap_node_anchors": true,
25"snap_node_center": true,
26"snap_node_parent": true,
27"snap_node_sides": true,
28"snap_other_nodes": true,
29"snap_pixel": false,
30"snap_relative": false,
31"snap_rotation": false,
32"snap_rotation_offset": 0.0,
33"snap_rotation_step": 0.261799,
34"snap_scale": false,
35"snap_scale_step": 0.1,
36"zoom": 0.594604
37}
383D={
39"fov": 70.0,
40"gizmos_status": {
41"AudioStreamPlayer3D": 0,
42"BakedLightmap": 0,
43"CPUParticles3D": 0,
44"CSGShape3D": 0,
45"Camera3D": 0,
46"CollisionObject3D": 0,
47"CollisionPolygon3D": 0,
48"CollisionShape3D": 0,
49"Decal": 0,
50"GIProbe": 0,
51"GPUParticles3D": 0,
52"GPUParticlesCollision3D": 0,
53"Joint3D": 0,
54"Light3D": 0,
55"LightmapProbe": 0,
56"NavigationRegion3D": 0,
57"OccluderInstance3D": 0,
58"Path3D": 0,
59"PhysicalBone3D": 0,
60"Position3D": 0,
61"RayCast3D": 0,
62"ReflectionProbe": 0,
63"Skeleton3D": 0,
64"SoftBody3D": 0,
65"SpringArm3D": 0,
66"VehicleWheel3D": 0,
67"VisibilityNotifier3D": 0
68},
69"local_coords": false,
70"preview_sun_env": {
71"environ_ao_enabled": false,
72"environ_disabled": false,
73"environ_energy": 1.0,
74"environ_gi_enabled": false,
75"environ_glow_enabled": true,
76"environ_ground_color": Color( 0.121569, 0.121569, 0.129412, 1 ),
77"environ_sky_color": Color( 0.568627, 0.698039, 0.807843, 1 ),
78"environ_tonemap_enabled": true,
79"sun_color": Color( 1, 1, 1, 1 ),
80"sun_disabled": false,
81"sun_energy": 1.0,
82"sun_max_distance": 250.0,
83"sun_rotation": Basis( -0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, 0.5, -0.5 )
84},
85"rotate_snap": 15.0,
86"scale_snap": 10.0,
87"show_grid": true,
88"show_origin": true,
89"snap_enabled": false,
90"translate_snap": 1.0,
91"viewport_mode": 1,
92"viewports": [ {
93"auto_orthogonal": false,
94"auto_orthogonal_enabled": true,
95"cinematic_preview": false,
96"display_mode": 19,
97"distance": 4.0,
98"doppler": false,
99"frame_time": false,
100"gizmos": true,
101"half_res": false,
102"information": false,
103"listener": true,
104"position": Vector3( 0, 0, 0 ),
105"use_environment": false,
106"use_orthogonal": false,
107"view_name": "",
108"x_rotation": 0.5,
109"y_rotation": -0.5
110}, {
111"auto_orthogonal": false,
112"auto_orthogonal_enabled": true,
113"cinematic_preview": false,
114"display_mode": 19,
115"distance": 4.0,
116"doppler": false,
117"frame_time": false,
118"gizmos": true,
119"half_res": false,
120"information": false,
121"listener": false,
122"position": Vector3( 0, 0, 0 ),
123"use_environment": false,
124"use_orthogonal": false,
125"view_name": "",
126"x_rotation": 0.5,
127"y_rotation": -0.5
128}, {
129"auto_orthogonal": false,
130"auto_orthogonal_enabled": true,
131"cinematic_preview": false,
132"display_mode": 19,
133"distance": 4.0,
134"doppler": false,
135"frame_time": false,
136"gizmos": true,
137"half_res": false,
138"information": false,
139"listener": false,
140"position": Vector3( 0, 0, 0 ),
141"use_environment": false,
142"use_orthogonal": false,
143"view_name": "",
144"x_rotation": 0.5,
145"y_rotation": -0.5
146}, {
147"auto_orthogonal": false,
148"auto_orthogonal_enabled": true,
149"cinematic_preview": false,
150"display_mode": 19,
151"distance": 4.0,
152"doppler": false,
153"frame_time": false,
154"gizmos": true,
155"half_res": false,
156"information": false,
157"listener": false,
158"position": Vector3( 0, 0, 0 ),
159"use_environment": false,
160"use_orthogonal": false,
161"view_name": "",
162"x_rotation": 0.5,
163"y_rotation": -0.5
164} ],
165"zfar": 4000.0,
166"znear": 0.05
167}
168TextureRegion={
169"snap_mode": 0,
170"snap_offset": Vector2( 0, 0 ),
171"snap_separation": Vector2( 0, 0 ),
172"snap_step": Vector2( 10, 10 )
173}
.godot/editor/HyperLoad.tscn-folding-bf53ee672d2552cd7d04dd13139dfd05.cfg +5 -0
……@@ -0,0 +1,5 @@
1[folding]
2
3node_unfolds=[ NodePath("."), PackedStringArray( "Rect" ), NodePath("Title"), PackedStringArray( "Rect", "Size Flags", "Structured Text" ), NodePath("HBoxContainer"), PackedStringArray( "Rect" ), NodePath("HBoxContainer/URLBar"), PackedStringArray( "Caret", "Rect", "Size Flags", "Structured Text" ), NodePath("HBoxContainer/LoadButton"), PackedStringArray( "Rect" ), NodePath("ScrollContainer"), PackedStringArray( "Rect", "Scroll", "Size Flags" ), NodePath("ScrollContainer/Output"), PackedStringArray( "Size Flags", "Structured Text" ), NodePath("StatusLabel"), PackedStringArray( "Rect", "Structured Text" ) ]
4resource_unfolds=[ ]
5nodes_folded=[ ]
.godot/editor/editor_layout.cfg +51 -0
……@@ -0,0 +1,51 @@
1[docks]
2
3dock_3="Scene,Import"
4dock_4="FileSystem"
5dock_5="Inspector,Node"
6dock_filesystem_split=0
7dock_filesystem_display_mode=0
8dock_filesystem_file_sort=0
9dock_filesystem_file_list_display_mode=1
10dock_split_2=0
11dock_split_3=0
12dock_hsplit_1=0
13dock_hsplit_2=70
14dock_hsplit_3=-70
15dock_hsplit_4=0
16
17[EditorNode]
18
19open_scenes=[ "res://src/HyperLoad.tscn" ]
20
21[ScriptEditor]
22
23open_scripts=[ {
24"path": "res://src/GatewayRequest.gd",
25"state": {
26"bookmarks": [ ],
27"breakpoints": [ ],
28"column": 39,
29"folded_lines": PackedInt32Array( ),
30"h_scroll_position": 0,
31"row": 43,
32"scroll_position": 32.0,
33"selection": false,
34"syntax_highlighter": "GDScript"
35}
36}, {
37"path": "res://src/ResizeRoot.gd",
38"state": {
39"bookmarks": [ ],
40"breakpoints": [ ],
41"column": 0,
42"folded_lines": PackedInt32Array( ),
43"h_scroll_position": 0,
44"row": 0,
45"scroll_position": 0.0,
46"selection": false,
47"syntax_highlighter": "GDScript"
48}
49} ]
50open_help=[ ]
51split_offset=70
.godot/editor/filesystem_cache6 +12 -0
……@@ -0,0 +1,12 @@
13844edc3d1660e6e25a999aafc25a878
2::res://::1622251215
3default_env.tres::Environment::1622100229::0::1::::<><>::
4icon.png::StreamTexture2D::1621449955::1622251219::1::::<><>::
5::res://hyper-gateway/::1622100176
6::res://src/::1622245301
7GatewayRequest.gd::GDScript::1622094645::0::1::::<>HTTPRequest<>::
8HyperLoad.tscn::PackedScene::1622100229::0::1::::<><>::res://src/URLBar.gd<>res://src/GatewayRequest.gd<>res://src/StatusLabel.gd<>res://src/Output.gd<>res://src/ResizeRoot.gd
9Output.gd::GDScript::1622094345::0::1::::<>RichTextLabel<>::
10ResizeRoot.gd::GDScript::1622084757::0::1::::<>VBoxContainer<>::
11StatusLabel.gd::GDScript::1622094484::0::1::::<>Label<>::
12URLBar.gd::GDScript::1621968967::0::1::::<>LineEdit<>::
.godot/editor/filesystem_update4 +2 -0
……@@ -0,0 +1,2 @@
1res://src/GatewayRequest.gd
2res://src/HyperLoad.tscn
.godot/editor/project_metadata.cfg +13 -0
……@@ -0,0 +1,13 @@
1[editor_metadata]
2
3executable_path="/home/mauve/programming/godot/source/bin/godot.linuxbsd.tools.64"
4
5[debug_options]
6
7run_live_debug=true
8run_reload_scripts=true
9
10[recent_files]
11
12scenes=[ "res://src/HyperLoad.tscn" ]
13scripts=[ "res://src/GatewayRequest.gd", "res://src/ResizeRoot.gd" ]
.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 +3 -0
……@@ -0,0 +1,3 @@
1source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
2dest_md5="99b07af0f62c2854ca2010c2a394dc11"
3
.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex +0 -0
(no content changes — binary or rename)
hyper-gateway/hyper-gateway-windows.exe +0 -0
(no content changes — binary or rename)
src/GatewayRequest.gd +0 -91
……@@ -1,91 +0,0 @@
1extends HTTPRequest
2
3signal loaded_data(data)
4signal loading_data(url)
5signal failed_load(url, error)
6signal starting_gateway()
7signal started_gateway(pid)
8
9var processPID = 0
10var storageDirectory = defaultDirectory()
11
12# Called when the node enters the scene tree for the first time.
13func _ready():
14 pass # Replace with function body.
15
16func _notification(what):
17 if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
18 cleanupGateway()
19 pass
20
21func cleanupGateway():
22 if processPID == 0:
23 print('Gateway already closed ' + str(processPID))
24 return
25 print('Cleaning up gateway ' + str(processPID))
26 OS.kill(processPID)
27 pass
28
29func setupGateway():
30 emit_signal("starting_gateway")
31 var executiblePath = getExecutiblePath()
32 var executibleFile = File.new()
33
34 executibleFile.open(executiblePath, File.READ)
35
36 var path = executibleFile.get_path_absolute()
37 executibleFile.close()
38
39 var args = ["run", "--no-persist"]
40
41 print("Starting gateway from " + path)
42
43 # Start the hyper-gateway in a process
44 processPID = OS.execute(path, args, false)
45
46 # Sleep for a bit while the gateway loads
47 # TODO: Find a better indicator like polling the HTTP server socket
48 OS.delay_msec(2000)
49
50 print("Started gateway at " + str(processPID))
51 emit_signal("started_gateway", processPID)
52 pass
53
54func ensureSetup():
55 if processPID != 0: return
56 setupGateway()
57 pass
58
59func getExecutiblePath():
60 var name = OS.get_name()
61 if name == 'X11': return "res://hyper-gateway/hyper-gateway-linux"
62 if name == 'OSX': return "res://hyper-gateway/hyper-gateway-macos"
63 if name == 'Windows': return "res://hyper-gateway/hyper-gateway-windows.exe"
64 push_error("Can not start gateway, invalid operating system " + name)
65 pass
66
67func defaultDirectory():
68 var dir = Directory.new()
69 dir.open('user://gateway-data/')
70 return dir.get_current_dir()
71 pass
72
73# Called every frame. 'delta' is the elapsed time since the previous frame.
74#func _process(delta):
75# pass
76
77func requestHyper(url):
78 ensureSetup()
79 var toload = url.replace("hyper://", "http://127.0.0.1:4973/hyper/")
80 print("Loading " + toload)
81 request(toload)
82 pass
83
84func _on_request_completed(result, response_code, headers, body):
85 print("Response Code ", response_code)
86 if response_code != 200:
87 var message = body.get_string_from_utf8()
88 print("Error message:", message)
89 emit_signal("failed_load", result, message)
90 else: emit_signal("loaded_data", body.get_string_from_utf8())
91 pass # Replace with function body.
src/HyperLoad.tscn +8 -12
……@@ -1,7 +1,7 @@
11[gd_scene load_steps=6 format=2]
22
33[ext_resource path="res://src/URLBar.gd" type="Script" id=1]
4[ext_resource path="res://src/GatewayRequest.gd" type="Script" id=2]
4[ext_resource path="res://src/HyperRequest.gd" type="Script" id=2]
55[ext_resource path="res://src/StatusLabel.gd" type="Script" id=3]
66[ext_resource path="res://src/Output.gd" type="Script" id=4]
77[ext_resource path="res://src/ResizeRoot.gd" type="Script" id=5]
……@@ -52,20 +52,21 @@ __meta__ = {
5252[node name="ScrollContainer" type="ScrollContainer" parent="."]
5353margin_top = 46.0
5454margin_right = 280.0
55margin_bottom = 46.0
55margin_bottom = 58.0
5656size_flags_vertical = 3
5757scroll_horizontal_enabled = false
5858
5959[node name="Output" type="RichTextLabel" parent="ScrollContainer"]
6060margin_right = 280.0
61margin_bottom = 12.0
6162size_flags_horizontal = 3
6263size_flags_vertical = 3
6364script = ExtResource( 4 )
6465
6566[node name="StatusLabel" type="Label" parent="."]
66margin_top = 50.0
67margin_top = 62.0
6768margin_right = 280.0
68margin_bottom = 64.0
69margin_bottom = 76.0
6970text = "Status: Waiting"
7071script = ExtResource( 3 )
7172__meta__ = {
……@@ -76,12 +77,7 @@ __meta__ = {
7677script = ExtResource( 2 )
7778
7879[connection signal="text_entered" from="HBoxContainer/URLBar" to="HBoxContainer/URLBar" method="_on_URLBar_text_entered"]
79[connection signal="url" from="HBoxContainer/URLBar" to="HyperLoad" method="requestHyper"]
80[connection signal="url" from="HBoxContainer/URLBar" to="HyperLoad" method="request"]
8081[connection signal="pressed" from="HBoxContainer/LoadButton" to="HBoxContainer/URLBar" method="navigate"]
81[connection signal="failed_load" from="HyperLoad" to="StatusLabel" method="setError"]
82[connection signal="loaded_data" from="HyperLoad" to="StatusLabel" method="setLoaded"]
83[connection signal="loaded_data" from="HyperLoad" to="ScrollContainer/Output" method="setContent"]
84[connection signal="loading_data" from="HyperLoad" to="StatusLabel" method="setLoadingData"]
85[connection signal="request_completed" from="HyperLoad" to="HyperLoad" method="_on_request_completed"]
86[connection signal="started_gateway" from="HyperLoad" to="StatusLabel" method="setGatewayLoaded"]
87[connection signal="starting_gateway" from="HyperLoad" to="StatusLabel" method="setGatewayLoading"]
82[connection signal="request_completed" from="HyperLoad" to="StatusLabel" method="_on_HyperLoad_request_completed"]
83[connection signal="request_completed" from="HyperLoad" to="ScrollContainer/Output" method="_on_HyperLoad_request_completed"]
src/HyperRequest.gd +83 -0
……@@ -0,0 +1,83 @@
1extends HTTPRequest
2
3signal loaded_data(data)
4signal loading_data(url)
5signal failed_load(url, error)
6signal starting_gateway()
7signal started_gateway(pid)
8
9var processPID = 0
10var storageDirectory = defaultDirectory()
11var serverPrefix = "http://127.0.0.1:4973/hyper/"
12
13# Called when the node enters the scene tree for the first time.
14func _ready():
15 pass # Replace with function body.
16
17func _notification(what):
18 if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
19 cleanupGateway()
20 pass
21
22func cleanupGateway():
23 if processPID == 0:
24 print('Gateway already closed ' + str(processPID))
25 return
26 print('Cleaning up gateway ' + str(processPID))
27 OS.kill(processPID)
28 pass
29
30func setupGateway():
31 emit_signal("starting_gateway")
32 var executiblePath = getExecutiblePath()
33 var executibleFile = File.new()
34
35 executibleFile.open(executiblePath, File.READ)
36
37 var path = executibleFile.get_path_absolute()
38 executibleFile.close()
39
40 var args = ["run", "--no-persist"]
41
42 print("Starting gateway from " + path)
43
44 # Start the hyper-gateway in a process
45 processPID = OS.execute(path, args, false)
46
47 # Sleep for a bit while the gateway loads
48 # TODO: Find a better indicator like polling the HTTP server socket
49 OS.delay_msec(2000)
50
51 print("Started gateway at " + str(processPID))
52 emit_signal("started_gateway", processPID)
53 pass
54
55func ensureSetup():
56 if processPID != 0: return
57 setupGateway()
58 pass
59
60func getExecutiblePath():
61 var name = OS.get_name()
62 if name == 'X11': return "res://hyper-gateway/hyper-gateway-linux"
63 if name == 'OSX': return "res://hyper-gateway/hyper-gateway-macos"
64 if name == 'Windows': return "res://hyper-gateway/hyper-gateway-windows.exe"
65 push_error("Can not start gateway, invalid operating system " + name)
66 pass
67
68func defaultDirectory():
69 var dir = Directory.new()
70 dir.open('user://gateway-data/')
71 return dir.get_current_dir()
72 pass
73
74# Called every frame. 'delta' is the elapsed time since the previous frame.
75#func _process(delta):
76# pass
77
78func request(url, custom_headers=PoolStringArray( ), ssl_validate_domain=false, method=0, request_data=""):
79 assert(url.begins_with("hyper://"))
80 ensureSetup()
81 var toLoad = url.replace("hyper://", serverPrefix)
82 .request(toLoad, custom_headers, ssl_validate_domain, method, request_data)
83 pass
src/Output.gd +2 -2
……@@ -1,5 +1,5 @@
11extends RichTextLabel
22
3func setContent(data):
4 text = data
3func _on_HyperLoad_request_completed(result, response_code, headers, body):
4 text = body.get_string_from_utf8()
55 pass # Replace with function body.
src/ScrollContainer.vs +0 -0
(no content changes — binary or rename)
src/StatusLabel.gd +12 -2
……@@ -14,7 +14,7 @@ func _ready():
1414#func _process(delta):
1515# pass
1616
17func setLoaded(data):
17func setLoaded():
1818 text = "Status: Loaded"
1919 pass # Replace with function body.
2020
……@@ -23,7 +23,7 @@ func setLoading(url):
2323 pass # Replace with function body.
2424
2525
26func setError(url, error):
26func setError(error):
2727 text = "Status: Failed Load" + error
2828 pass # Replace with function body.
2929
……@@ -36,3 +36,13 @@ func setGatewayLoading():
3636func setGatewayLoaded(pid):
3737 text = "Status: Gateway Loaded"
3838 pass # Replace with function body.
39
40
41func _on_HyperLoad_request_completed(result, response_code, headers, body):
42 print("Response Code ", response_code)
43 if response_code != 200:
44 var message = body.get_string_from_utf8()
45 print("Error message:", message)
46 setError(message)
47 else: setLoaded()
48 pass # Replace with function body.