forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add missing access token and discord fixes
remove godot steam module update update update stuff Update blazium_sdk update123 update update docs update default stuff
- Loading branch information
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
Submodule blazium_sdk
updated
21 files
+1 −1 | .gitignore | |
+236 −40 | discord/discord_embedded_app_client.cpp | |
+11 −4 | discord/discord_embedded_app_client.h | |
+19 −6 | discord/discord_embedded_app_response.h | |
+57 −25 | doc_classes/DiscordEmbeddedAppClient.xml | |
+11 −0 | doc_classes/DiscordEmbeddedAppResult.xml | |
+1 −0 | doc_classes/LobbyClient.xml | |
+3 −1 | doc_classes/LoginClient.xml | |
+2 −2 | doc_classes/LoginResponse.xml | |
+1 −0 | doc_classes/MasterServerClient.xml | |
+1 −0 | doc_classes/ScriptedLobbyClient.xml | |
+7 −0 | lobby/lobby_client.cpp | |
+1 −1 | lobby/lobby_client.h | |
+30 −0 | lobby/lobby_info.cpp | |
+30 −0 | lobby/lobby_peer.cpp | |
+7 −0 | lobby/scripted_lobby_client.cpp | |
+1 −1 | lobby/scripted_lobby_client.h | |
+42 −5 | login/login_client.cpp | |
+30 −4 | login/login_client.h | |
+10 −1 | master_server/master_server_client.h | |
+1 −1 | readme.md |
21 changes: 21 additions & 0 deletions
21
modules/gdscript/editor/script_templates/DiscordEmbeddedAppClient/default.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends DiscordEmbeddedAppClient | ||
|
||
func _init() -> void: | ||
log_updated.connect(_log_updated) | ||
|
||
# Only run this on discord embedded app environment | ||
if is_discord_environment(): | ||
var result:DiscordEmbeddedAppResult = await is_ready().finished | ||
if result.has_error(): | ||
push_error(result.error) | ||
return | ||
|
||
func do_authorize() -> void: | ||
var result = await authorize("code", "", "none", ["identify"]).finished | ||
if result.data.has("code"): | ||
print(result.data) | ||
else: | ||
push_error("Cannot authorize ", result.data) | ||
|
||
func _log_updated(command: String, message: String): | ||
print("DiscordEmbeddedAppClient: ", command, ": ", message) |
39 changes: 39 additions & 0 deletions
39
modules/gdscript/editor/script_templates/LobbyClient/default.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
extends LobbyClient | ||
|
||
@export var reconnects = 0 | ||
var config: ConfigFile | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready() -> void: | ||
config = ConfigFile.new() | ||
config.load("user://blazium.cfg") | ||
|
||
reconnection_token = config.get_value("LobbyClient", "reconnection_token", "") | ||
|
||
disconnected_from_lobby.connect(_disconnected_from_lobby) | ||
log_updated.connect(_log_updated) | ||
connected_to_lobby.connect(_connected_to_lobby) | ||
|
||
connect_to_lobby() | ||
|
||
func _log_updated(command: String, message: String): | ||
print("LobbyClient: ", command, ": ", message) | ||
|
||
func _connected_to_lobby(_peer: LobbyPeer, new_reconnection_token: String): | ||
reconnects = 0 | ||
config.set_value("LobbyClient", "reconnection_token", new_reconnection_token) | ||
var err = config.save("user://blazium.cfg") | ||
if err != OK: | ||
push_error(error_string(err)) | ||
|
||
func _disconnected_from_lobby(reason: String): | ||
if reason == "Reconnect Close": | ||
reconnection_token = "" | ||
print("Disconnected. ", reason) | ||
if reconnects > 10: | ||
push_error("Cannot connect") | ||
return | ||
reconnects += 1 | ||
if is_inside_tree(): | ||
await get_tree().create_timer(0.5 * reconnects).timeout | ||
connect_to_lobby() |
28 changes: 28 additions & 0 deletions
28
modules/gdscript/editor/script_templates/LoginClient/default.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
extends LoginClient | ||
|
||
func _init() -> void: | ||
received_jwt.connect(_received_jwt) | ||
log_updated.connect(_log_updated) | ||
|
||
# Connect to the server | ||
var result = await connect_to_server().finished | ||
if result.has_error(): | ||
push_error(result.error) | ||
|
||
func request_login_and_open() -> void: | ||
# Get Login URL | ||
var login_result :LoginResult = await request_login_info("discord").finished | ||
if login_result.has_error(): | ||
push_error(login_result.error) | ||
return | ||
|
||
# Open Login URL and wait for received_jwt signal | ||
var error := OS.shell_open(login_result.login_url) | ||
if error != OK: | ||
push_error(error) | ||
|
||
func _log_updated(command: String, message: String): | ||
print("LoginClient: ", command, ": ", message) | ||
|
||
func _received_jwt(jwt: String, type: String, access_token: String): | ||
print("Got jwt and access_token", jwt, " ", type, " ", access_token) |
27 changes: 27 additions & 0 deletions
27
modules/gdscript/editor/script_templates/ScriptedLobbyClient/default.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extends LoginClient | ||
|
||
func _init() -> void: | ||
received_jwt.connect(_received_jwt) | ||
log_updated.connect(_log_updated) | ||
|
||
# Connect to the server | ||
var result = await connect_to_server().finished | ||
if result.has_error(): | ||
push_error(result.error) | ||
|
||
func request_login_and_open() -> void: | ||
# Get Login URL | ||
var login_result :LoginResult = await request_login_info("discord").finished | ||
if login_result.has_error(): | ||
push_error(login_result.error) | ||
|
||
# Open Login URL and wait for received_jwt signal | ||
var error := OS.shell_open(login_result.login_url) | ||
if error != OK: | ||
push_error(error) | ||
|
||
func _log_updated(command: String, message: String): | ||
print("LoginClient: ", command, ": ", message) | ||
|
||
func _received_jwt(jwt: String, type: String, access_token: String): | ||
print("Godt jwt and access_token", jwt, " ", type, " ", access_token) |