Skip to content

Support for await keyword in the Godot SDK #58

@treepumpkin

Description

@treepumpkin

Godot 4 introduced the await keyword for coroutines, it would be nice to use it in this SDK, too. Here is an example with the login_as_new_guest_user call.

Current SDK usage:

func _ready():
	
	# Get the SDK and Init
	self.aws_game_sdk = get_node("/root/AwsGameSdk")
	self.aws_game_sdk.init(self.login_endpoint, self.on_login_error)
	
	# Log in as new guest user first
	self.aws_game_sdk.login_as_new_guest_user(self.login_as_guest_callback)

# Called on any login or token refresh failures
func on_login_error(message):
	print("Login error: " + message)

# Receives a UserInfo object after successful guest login
func login_as_guest_callback(user_info):
	print("Received guest login info.")
	print(user_info)

	# Try linking Steam ID to existing user
	# NOTE: You need to use the Godot Steamworks SDK (https://godotsteam.com/) to integrate with Steam
	#       Use the GetAuthTicketForWebAPI to get the steam auth token (https://godotsteam.com/functions/users/#getauthticketforwebapi)
	self.aws_game_sdk.link_steam_id_to_current_user("YourTokenHere", self.on_link_steam_id_response)
	

Desired SDK usage (same pattern as in W4 Cloud's SDK )

func _ready():

	# Get the SDK and Init
	self.aws_game_sdk = get_node("/root/AwsGameSdk")

	var res = await self.aws_game_sdk.login_as_new_guest_user().async()

	if res.is_error():
		print("Error!:" + res.as_error())
		return

	print("Received guest login info.")
	print(res.get_data())

	# Try linking Steam ID to existing user
	# NOTE: You need to use the Godot Steamworks SDK (https://godotsteam.com/) to integrate with Steam
	#       Use the GetAuthTicketForWebAPI to get the steam auth token (https://godotsteam.com/functions/users/#getauthticketforwebapi)
	res = await aws_game_sdk.link_steam_id_to_current_user("YourTokenHere").async()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions