MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / poll_events

Method poll_events

core/debugger/remote_debugger.cpp:634–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634void RemoteDebugger::poll_events(bool p_is_idle) {
635 if (peer.is_null()) {
636 return;
637 }
638
639 flush_output();
640
641 _poll_messages();
642
643 while (_has_messages()) {
644 Array arr = _get_message();
645
646 ERR_CONTINUE(arr.size() != 2);
647 ERR_CONTINUE(arr[0].get_type() != Variant::STRING);
648 ERR_CONTINUE(arr[1].get_type() != Variant::ARRAY);
649
650 const String cmd = arr[0];
651 const int idx = cmd.find_char(':');
652 bool parsed = false;
653 if (idx < 0) { // Not prefix, use scripts capture.
654 capture_parse("core", cmd, arr[1], parsed);
655 continue;
656 }
657
658 const String cap = cmd.substr(0, idx);
659 if (!has_capture(cap)) {
660 continue; // Unknown message...
661 }
662
663 const String msg = cmd.substr(idx + 1);
664 capture_parse(cap, msg, arr[1], parsed);
665 }
666
667 // Reload scripts during idle poll only.
668 if (p_is_idle) {
669 if (reload_all_scripts) {
670 for (int i = 0; i < ScriptServer::get_language_count(); i++) {
671 ScriptServer::get_language(i)->reload_all_scripts();
672 }
673 reload_all_scripts = false;
674 } else if (!script_paths_to_reload.is_empty()) {
675 Array scripts_to_reload;
676 for (int i = 0; i < script_paths_to_reload.size(); ++i) {
677 String path = script_paths_to_reload[i];
678 Error err = OK;
679 Ref<Script> script = ResourceLoader::load(path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
680 ERR_CONTINUE_MSG(err != OK, vformat("Could not reload script '%s': %s", path, error_names[err]));
681 ERR_CONTINUE_MSG(script.is_null(), vformat("Could not reload script '%s': Not a script!", path, error_names[err]));
682 scripts_to_reload.push_back(script);
683 }
684 for (int i = 0; i < ScriptServer::get_language_count(); i++) {
685 ScriptServer::get_language(i)->reload_scripts(scripts_to_reload, true);
686 }
687 }
688 script_paths_to_reload.clear();
689 }
690}
691

Callers 2

iterationMethod · 0.45
deinitializeMethod · 0.45

Calls 12

get_languageFunction · 0.85
vformatFunction · 0.85
find_charMethod · 0.80
substrMethod · 0.80
sizeMethod · 0.65
is_nullMethod · 0.45
get_typeMethod · 0.45
reload_all_scriptsMethod · 0.45
is_emptyMethod · 0.45
push_backMethod · 0.45
reload_scriptsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected