[Editor] Editor debugger binds according to editor settings.
This commit is contained in:
parent
4d08a737fb
commit
ecb2e8297c
6 changed files with 30 additions and 15 deletions
|
@ -182,16 +182,16 @@ ScriptEditorDebugger *EditorDebuggerNode::get_default_debugger() const {
|
||||||
return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0));
|
return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorDebuggerNode::start(const String &p_protocol) {
|
Error EditorDebuggerNode::start(const String &p_uri) {
|
||||||
stop();
|
stop();
|
||||||
|
ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER);
|
||||||
if (EDITOR_GET("run/output/always_open_output_on_play")) {
|
if (EDITOR_GET("run/output/always_open_output_on_play")) {
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
|
||||||
} else {
|
} else {
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
||||||
}
|
}
|
||||||
|
server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create(p_uri.substr(0, p_uri.find("://") + 3)));
|
||||||
server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create(p_protocol));
|
const Error err = server->start(p_uri);
|
||||||
const Error err = server->start();
|
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ public:
|
||||||
void set_camera_override(CameraOverride p_override);
|
void set_camera_override(CameraOverride p_override);
|
||||||
CameraOverride get_camera_override();
|
CameraOverride get_camera_override();
|
||||||
|
|
||||||
Error start(const String &p_protocol = "tcp://");
|
Error start(const String &p_uri = "tcp://");
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ private:
|
||||||
public:
|
public:
|
||||||
static EditorDebuggerServer *create(const String &p_protocol);
|
static EditorDebuggerServer *create(const String &p_protocol);
|
||||||
virtual void poll() {}
|
virtual void poll() {}
|
||||||
virtual Error start();
|
virtual Error start(const String &p_uri);
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual bool is_active() const;
|
virtual bool is_active() const;
|
||||||
virtual bool is_connection_available() const;
|
virtual bool is_connection_available() const;
|
||||||
|
@ -63,11 +63,18 @@ EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
|
||||||
server.instantiate();
|
server.instantiate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorDebuggerServerTCP::start() {
|
Error EditorDebuggerServerTCP::start(const String &p_uri) {
|
||||||
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||||
const Error err = server->listen(remote_port);
|
String bind_host = (String)EditorSettings::get_singleton()->get("network/debug/remote_host");
|
||||||
|
if (!p_uri.is_empty() && p_uri != "tcp://") {
|
||||||
|
String scheme, path;
|
||||||
|
Error err = p_uri.parse_url(scheme, bind_host, bind_port, path);
|
||||||
|
ERR_FAIL_COND_V(err != OK, ERR_INVALID_PARAMETER);
|
||||||
|
ERR_FAIL_COND_V(!bind_host.is_valid_ip_address() && bind_host != "*", ERR_INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
const Error err = server->listen(bind_port, bind_host);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
EditorNode::get_log()->add_message(String("Error listening on port ") + itos(remote_port), EditorLog::MSG_TYPE_ERROR);
|
EditorNode::get_log()->add_message(String("Error listening on port ") + itos(bind_port), EditorLog::MSG_TYPE_ERROR);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func);
|
static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func);
|
||||||
static EditorDebuggerServer *create(const String &p_protocol);
|
static EditorDebuggerServer *create(const String &p_protocol);
|
||||||
virtual void poll() = 0;
|
virtual void poll() = 0;
|
||||||
virtual Error start() = 0;
|
virtual Error start(const String &p_uri = "") = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual bool is_active() const = 0;
|
virtual bool is_active() const = 0;
|
||||||
virtual bool is_connection_available() const = 0;
|
virtual bool is_connection_available() const = 0;
|
||||||
|
|
|
@ -48,11 +48,19 @@ void EditorDebuggerServerWebSocket::poll() {
|
||||||
server->poll();
|
server->poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorDebuggerServerWebSocket::start() {
|
Error EditorDebuggerServerWebSocket::start(const String &p_uri) {
|
||||||
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||||
|
String bind_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
|
||||||
|
if (!p_uri.is_empty() && p_uri != "ws://") {
|
||||||
|
String scheme, path;
|
||||||
|
Error err = p_uri.parse_url(scheme, bind_host, bind_port, path);
|
||||||
|
ERR_FAIL_COND_V(err != OK, ERR_INVALID_PARAMETER);
|
||||||
|
ERR_FAIL_COND_V(!bind_host.is_valid_ip_address() && bind_host != "*", ERR_INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
server->set_bind_ip(bind_host);
|
||||||
Vector<String> compatible_protocols;
|
Vector<String> compatible_protocols;
|
||||||
compatible_protocols.push_back("binary"); // compatibility with EMSCRIPTEN TCP-to-WebSocket layer.
|
compatible_protocols.push_back("binary"); // compatibility with EMSCRIPTEN TCP-to-WebSocket layer.
|
||||||
return server->listen(remote_port, compatible_protocols);
|
return server->listen(bind_port, compatible_protocols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorDebuggerServerWebSocket::stop() {
|
void EditorDebuggerServerWebSocket::stop() {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
void _peer_disconnected(int p_peer, bool p_was_clean);
|
void _peer_disconnected(int p_peer, bool p_was_clean);
|
||||||
|
|
||||||
void poll() override;
|
void poll() override;
|
||||||
Error start() override;
|
Error start(const String &p_uri) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
bool is_active() const override;
|
bool is_active() const override;
|
||||||
bool is_connection_available() const override;
|
bool is_connection_available() const override;
|
||||||
|
|
Loading…
Reference in a new issue