more signals
This commit is contained in:
@@ -2,3 +2,12 @@ extends DiscordConnector
|
|||||||
|
|
||||||
func _on_user_connected(access_token: String, refresh_token: String, expires_in: int) -> void:
|
func _on_user_connected(access_token: String, refresh_token: String, expires_in: int) -> void:
|
||||||
print_debug("Access token: %s \nRefresh Token: %s \nExpires in: %s" % [access_token, refresh_token, expires_in])
|
print_debug("Access token: %s \nRefresh Token: %s \nExpires in: %s" % [access_token, refresh_token, expires_in])
|
||||||
|
|
||||||
|
func _on_user_updated() -> void:
|
||||||
|
print_debug("USER UPDATED")
|
||||||
|
|
||||||
|
func _on_user_connection_failed(error: String) -> void:
|
||||||
|
push_error("User connection failed! Error: %s", error)
|
||||||
|
|
||||||
|
func _on_user_update_failed(error: String) -> void:
|
||||||
|
push_error("User update failed! Error: %s", error)
|
||||||
|
@@ -49,3 +49,6 @@ encryption_key = "H8jOL;.+F9B7&/jLb:Yr_,V'He/nRQw.wII8GE1$l_P,&YG)Yc"
|
|||||||
script = ExtResource("3_h2yge")
|
script = ExtResource("3_h2yge")
|
||||||
|
|
||||||
[connection signal="user_connected" from="DiscordConnector" to="DiscordConnector" method="_on_user_connected"]
|
[connection signal="user_connected" from="DiscordConnector" to="DiscordConnector" method="_on_user_connected"]
|
||||||
|
[connection signal="user_connection_failed" from="DiscordConnector" to="DiscordConnector" method="_on_user_connection_failed"]
|
||||||
|
[connection signal="user_update_failed" from="DiscordConnector" to="DiscordConnector" method="_on_user_update_failed"]
|
||||||
|
[connection signal="user_updated" from="DiscordConnector" to="DiscordConnector" method="_on_user_updated"]
|
||||||
|
@@ -9,11 +9,14 @@ void DiscordConnector::_bind_methods()
|
|||||||
BIND_SET_GET(DiscordConnector, encryption_key, Variant::STRING, godot::PROPERTY_HINT_PASSWORD);
|
BIND_SET_GET(DiscordConnector, encryption_key, Variant::STRING, godot::PROPERTY_HINT_PASSWORD);
|
||||||
BIND_SET_GET(DiscordConnector, token_auto_manage, Variant::BOOL);
|
BIND_SET_GET(DiscordConnector, token_auto_manage, Variant::BOOL);
|
||||||
BIND_METHOD(DiscordConnector, connect_user);
|
BIND_METHOD(DiscordConnector, connect_user);
|
||||||
BIND_METHOD(DiscordConnector, update_user_token);
|
BIND_METHOD(DiscordConnector, update_user_token, "access_token");
|
||||||
BIND_METHOD(DiscordConnector, get_access_token);
|
BIND_METHOD(DiscordConnector, get_access_token);
|
||||||
BIND_METHOD(DiscordConnector, get_refresh_token);
|
BIND_METHOD(DiscordConnector, get_refresh_token);
|
||||||
BIND_METHOD(DiscordConnector, get_expires_in);
|
BIND_METHOD(DiscordConnector, get_expires_in);
|
||||||
BIND_SIGNAL(user_connected, PropertyInfo(Variant::STRING, "access_token"), PropertyInfo(Variant::STRING, "refresh_token"), PropertyInfo(Variant::INT, "expires_in"));
|
BIND_SIGNAL(user_connected, PropertyInfo(Variant::STRING, "access_token"), PropertyInfo(Variant::STRING, "refresh_token"), PropertyInfo(Variant::INT, "expires_in"));
|
||||||
|
BIND_SIGNAL(user_connection_failed, PropertyInfo(Variant::STRING, "error"));
|
||||||
|
BIND_SIGNAL(user_updated);
|
||||||
|
BIND_SIGNAL(user_update_failed, PropertyInfo(Variant::STRING, "error"));
|
||||||
}
|
}
|
||||||
DiscordConnector::DiscordConnector()
|
DiscordConnector::DiscordConnector()
|
||||||
{
|
{
|
||||||
@@ -142,10 +145,10 @@ void DiscordConnector::connect_user()
|
|||||||
{
|
{
|
||||||
DiscordUtil::get_singleton()->save_tokens(accessToken.c_str(), refreshToken.c_str(), expiresIn, encryption_key);
|
DiscordUtil::get_singleton()->save_tokens(accessToken.c_str(), refreshToken.c_str(), expiresIn, encryption_key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UtilityFunctions::push_error("Access token error: " + String(result.Error().c_str()));
|
emit_signal("user_connection_failed", result.Error().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
update_user_token(accessToken.c_str());
|
update_user_token(accessToken.c_str());
|
||||||
});
|
});
|
||||||
} });
|
} });
|
||||||
@@ -157,8 +160,9 @@ void DiscordConnector::update_user_token(String access_token)
|
|||||||
{
|
{
|
||||||
if(result.Successful()) {
|
if(result.Successful()) {
|
||||||
client->Connect();
|
client->Connect();
|
||||||
|
emit_signal("user_updated");
|
||||||
} else {
|
} else {
|
||||||
UtilityFunctions::push_error("Token update error: " + String(result.Error().c_str()));
|
emit_signal("user_update_failed", result.Error().c_str());
|
||||||
} });
|
} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user