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

Method start

editor/debugger/editor_debugger_server.cpp:79–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79Error EditorDebuggerServerTCP::start(const String &p_uri) {
80 // Default host and port
81 String bind_host = (String)EDITOR_GET("network/debug/remote_host");
82 int bind_port = (int)EDITOR_GET("network/debug/remote_port");
83
84 // Optionally override
85 if (!p_uri.is_empty() && p_uri != "tcp://") {
86 String scheme, path, fragment;
87 Error err = p_uri.parse_url(scheme, bind_host, bind_port, path, fragment);
88 ERR_FAIL_COND_V(err != OK, ERR_INVALID_PARAMETER);
89 ERR_FAIL_COND_V(!bind_host.is_valid_ip_address() && bind_host != "*", ERR_INVALID_PARAMETER);
90 }
91
92 // Try listening on ports
93 const int max_attempts = 5;
94 for (int attempt = 1;; ++attempt) {
95 const Error err = server->listen(bind_port, bind_host);
96 if (err == OK) {
97 break;
98 }
99 if (attempt >= max_attempts) {
100 EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, remote debugging unavailable.", bind_port), EditorLog::MSG_TYPE_ERROR);
101 return err;
102 }
103 int last_port = bind_port++;
104 EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, trying %d instead.", last_port, bind_port), EditorLog::MSG_TYPE_WARNING);
105 }
106
107 // Endpoint that the client should connect to
108 endpoint = vformat("tcp://%s:%d", bind_host, bind_port);
109
110 return OK;
111}
112
113void EditorDebuggerServerTCP::stop() {
114 server->stop();

Callers

nothing calls this directly

Calls 6

vformatFunction · 0.85
parse_urlMethod · 0.80
is_valid_ip_addressMethod · 0.80
is_emptyMethod · 0.45
listenMethod · 0.45
add_messageMethod · 0.45

Tested by

no test coverage detected