summaryrefslogtreecommitdiffstats
path: root/editor/debugger/editor_debugger_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/debugger/editor_debugger_server.cpp')
-rw-r--r--editor/debugger/editor_debugger_server.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp
index c80988a662..33f20d9a12 100644
--- a/editor/debugger/editor_debugger_server.cpp
+++ b/editor/debugger/editor_debugger_server.cpp
@@ -44,6 +44,7 @@ private:
Ref<TCP_Server> server;
public:
+ static EditorDebuggerServer *create(const String &p_protocol);
virtual void poll() {}
virtual Error start();
virtual void stop();
@@ -54,6 +55,11 @@ public:
EditorDebuggerServerTCP();
};
+EditorDebuggerServer *EditorDebuggerServerTCP::create(const String &p_protocol) {
+ ERR_FAIL_COND_V(p_protocol != "tcp://", nullptr);
+ return memnew(EditorDebuggerServerTCP);
+}
+
EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
server.instance();
}
@@ -85,6 +91,23 @@ Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() {
return memnew(RemoteDebuggerPeerTCP(server->take_connection()));
}
-EditorDebuggerServer *EditorDebuggerServer::create_default() {
- return memnew(EditorDebuggerServerTCP);
+/// EditorDebuggerServer
+Map<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols;
+
+EditorDebuggerServer *EditorDebuggerServer::create(const String &p_protocol) {
+ ERR_FAIL_COND_V(!protocols.has(p_protocol), nullptr);
+ return protocols[p_protocol](p_protocol);
+}
+
+void EditorDebuggerServer::register_protocol_handler(const String &p_protocol, CreateServerFunc p_func) {
+ ERR_FAIL_COND(protocols.has(p_protocol));
+ protocols[p_protocol] = p_func;
+}
+
+void EditorDebuggerServer::initialize() {
+ register_protocol_handler("tcp://", EditorDebuggerServerTCP::create);
+}
+
+void EditorDebuggerServer::deinitialize() {
+ protocols.clear();
}