-
Notifications
You must be signed in to change notification settings - Fork 25
Godot 4 AWS Plugin v 1.0.0 #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Godot 4 AWS Plugin v 1.0.0 #66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting this PR. Your contribution is appreciated. I have reviewed your changes and left some comments for your consideration. Please take a moment to review these suggestions and make any necessary adjustments.
add_autoload_singleton(AUTOLOAD_NAME, "res://addons/AWSGameSDK/AWSAuthorization.gd") | ||
add_autoload_singleton(AUTOLOAD_NAME, "res://addons/AWSGameSDK/AWSBackend.gd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _enable_plugin()
function attempts to register two autoload singletons with the same name. This would cause a conflict as only one can be registered with a given name.
Recommended solution: Register only one autoload singleton or use different names for each:
func _enable_plugin():
add_autoload_singleton(AUTOLOAD_NAME_AUTH, "res://addons/AWSGameSDK/scripts/AWSAuthorization.gd")
add_autoload_singleton(AUTOLOAD_NAME_BACKEND, "res://addons/AWSGameSDK/scripts/AWSBackend.gd")
func _enable_plugin(): | ||
add_autoload_singleton(AUTOLOAD_NAME, "res://addons/AWSGameSDK/AWSAuthorization.gd") | ||
add_autoload_singleton(AUTOLOAD_NAME, "res://addons/AWSGameSDK/AWSBackend.gd") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin doesn't properly register the custom node types to make them available in the editor
Recommended solution:
Add proper node registration in the plugin script:
@tool
extends EditorPlugin
const AUTOLOAD_NAME_AUTH = "AWSGameSDKAuth"
const AUTOLOAD_NAME_BACKEND = "AWSGameSDKBackend"
func _enter_tree():
# Register custom node types
add_custom_type("AWSGameSDKAuth", "Node", preload("res://addons/AWSGameSDK/scripts/AWSAuthorization.gd"), preload("res://addons/AWSGameSDK/icon.png"))
add_custom_type("AWSGameSDKBackend", "Node", preload("res://addons/AWSGameSDK/scripts/AWSBackend.gd"), preload("res://addons/AWSGameSDK/icon.png"))
func _exit_tree():
# Remove custom node types
remove_custom_type("AWSGameSDKAuth")
remove_custom_type("AWSGameSDKBackend")
func _enable_plugin():
add_autoload_singleton(AUTOLOAD_NAME_AUTH, "res://addons/AWSGameSDK/scripts/AWSAuthorization.gd")
add_autoload_singleton(AUTOLOAD_NAME_BACKEND, "res://addons/AWSGameSDK/scripts/AWSBackend.gd")
func _disable_plugin():
remove_autoload_singleton(AUTOLOAD_NAME_AUTH)
remove_autoload_singleton(AUTOLOAD_NAME_BACKEND)
|
||
# trigger error if we didn't get a proper response code | ||
if(response_code >= 400): | ||
error_string = json_string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an HTTP request fails with a response code >= 400, it sets error_string
but doesn't emit any signal:
Recommended solution: Emit an error signal when HTTP requests fail:
if(response_code >= 400):
error_string = json_string
aws_login_error.emit("HTTP Error: " + str(response_code) + " - " + json_string)
return
var error = json.parse(json_string) | ||
|
||
# trigger error if we didn't get a proper response code | ||
if(response_code >= 400): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an HTTP request fails with a response code >= 400, it sets error_string
but doesn't emit any signal.
Recommended solution: Emit an error signal when HTTP requests fail:
if(response_code >= 400):
error_string = json_string
aws_login_error.emit("HTTP Error: " + str(response_code) + " - " + json_string)
return
|
||
|
||
func login(): | ||
if user_info.user_id == "" or user_info.guest_secret == "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The login()
function doesn't check if user_info
is null before accessing its properties.
Recommended solution: Add null check before accessing properties:
func login():
if user_info == null:
user_info = UserInfo.new()
_login_as_new_guest()
elif user_info.user_id == "" or user_info.guest_secret == "":
_login_as_new_guest()
else:
_login_as_guest()
aws_sdk_error.emit("Error making backend request") | ||
|
||
|
||
func _backend_reqeust_completed(result, response_code, headers, body): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in function name: _backend_reqeust_completed
print("AWS Game SDK initialized") | ||
|
||
|
||
func _make_auth_http_request(url: String, method: HTTPClient.Method = HTTPClient.METHOD_GET, form_data: Dictionary = {}) -> void: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function declares a form_data
parameter but doesn't use it.
func login_with_facebook_access_token(facebook_access_token, facebook_user_id) | ||
``` | ||
|
||
Supported signals are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended update: Add comprehensive signal documentation:
## Signal Reference
### AWSGameSDKAuth Signals
- `aws_login_success`: Emitted when login is successful. No parameters.
- `aws_login_error(message: String)`: Emitted when login fails. Provides an error message.
- `aws_sdk_error(message: String)`: Emitted when a general SDK error occurs. Provides an error message.
- `steam_link`: Emitted when Steam account linking is successful.
- `steam_login`: Emitted when Steam login is successful.
- `fb_link`: Emitted when Facebook account linking is successful.
- `fb_login`: Emitted when Facebook login is successful.
- `apple_link`: Emitted when Apple account linking is successful.
- `apple_login`: Emitted when Apple login is successful.
- `goog_link`: Emitted when Google Play account linking is successful.
- `goog_login`: Emitted when Google Play login is successful.
### AWSGameSDKBackend Signals
- `aws_backend_request_successful`: Emitted when a backend request completes successfully.
- `aws_sdk_error(message: String)`: Emitted when a backend request fails. Provides an error message.
``` | ||
|
||
## Adding the SDK to an existing project | ||
# Migrating from prior version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended update: Enhance the migration guide with signal connection examples:
## Migrating from Callback-based to Signal-based Approach
When migrating from the previous version's callback-based approach to the new signal-based approach, you'll need to replace callback function registrations with signal connections:
### Old (Callback-based):
```gdscript
self.aws_game_sdk.login_as_new_guest_user(self.login_callback)
New (Signal-based):
@onready var aws_games_sdk_auth = get_node("AWSGameSDKAuth")
func _ready():
aws_games_sdk_auth.aws_login_success.connect(_on_login_success)
aws_games_sdk_auth.aws_login_error.connect(_on_login_error)
aws_games_sdk_auth.login()
func _on_login_success():
print("Login successful!")
func _on_login_error(message):
print("Login failed: " + message)
@@ -0,0 +1,97 @@ | |||
# AWS Game Backend Framework Godot 4 SDK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file appears to be outdated documentation that was included in the PR version by mistake.
Issue #, if available:
Description of changes:
Moved AWSGameSDK to the addons folder and created a plugin that contains 2 components - Auth and Backend. Separated the two features into their own components so we can work on adding additional features (webscokets, analytics, etc) to the plugin without affecting core functionality.
Auth component changes/updates
3/ Backend component changes/updates
4/ Updated the samples to use the new plugin and methods. Also updated the readme to help developers add the plugin and configure it within their project.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.