feat: implemented full connection protocol (both)
This commit is contained in:
parent
acb7351ea7
commit
8086924141
12 changed files with 268 additions and 73 deletions
|
|
@ -1,8 +1,19 @@
|
|||
#include "client_node.h"
|
||||
#include "ydi_client.h"
|
||||
|
||||
String const ClientNode::sig_connection_changed{ "connection_changed" };
|
||||
|
||||
void ClientNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("connect_to_server"), &self_type::connect_to_server);
|
||||
ClassDB::bind_method(D_METHOD("connect_to_server", "server_url"), &self_type::connect_to_server);
|
||||
ADD_SIGNAL(MethodInfo(sig_connection_changed, PropertyInfo(Variant::INT, "connected", PROPERTY_HINT_ENUM, "Disconnected,Connected,Authenticated")));
|
||||
}
|
||||
|
||||
void ClientNode::process() {
|
||||
NetworkData::ConnectionStatus const new_status{ ydi::client::status() };
|
||||
if (new_status != this->state) {
|
||||
this->state = new_status;
|
||||
emit_signal(sig_connection_changed, new_status);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientNode::exit_tree() {
|
||||
|
|
@ -14,6 +25,12 @@ void ClientNode::_notification(int what) {
|
|||
return;
|
||||
}
|
||||
switch (what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
set_process(true);
|
||||
return;
|
||||
case NOTIFICATION_PROCESS:
|
||||
process();
|
||||
return;
|
||||
case NOTIFICATION_EXIT_TREE:
|
||||
exit_tree();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue