2017-12-21 02:13:23 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* register_types.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
2017-12-21 02:47:16 +00:00
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
2017-12-21 02:13:23 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-12-21 02:13:23 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2019-01-01 11:46:36 +00:00
|
|
|
|
2017-12-21 02:13:23 +00:00
|
|
|
#include "register_types.h"
|
2022-03-28 12:10:28 +00:00
|
|
|
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/error/error_macros.h"
|
2022-03-28 12:10:28 +00:00
|
|
|
|
2017-12-21 02:13:23 +00:00
|
|
|
#ifdef JAVASCRIPT_ENABLED
|
|
|
|
#include "emscripten.h"
|
|
|
|
#include "emws_client.h"
|
|
|
|
#include "emws_peer.h"
|
|
|
|
#include "emws_server.h"
|
|
|
|
#else
|
2019-06-24 13:46:24 +00:00
|
|
|
#include "wsl_client.h"
|
|
|
|
#include "wsl_server.h"
|
2017-12-21 02:13:23 +00:00
|
|
|
#endif
|
2022-03-28 12:10:28 +00:00
|
|
|
|
2020-03-16 16:02:14 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
#include "editor/debugger/editor_debugger_server.h"
|
2022-03-28 12:10:28 +00:00
|
|
|
#include "editor/editor_debugger_server_websocket.h"
|
2020-05-16 02:03:29 +00:00
|
|
|
#include "editor/editor_node.h"
|
2020-03-16 16:02:14 +00:00
|
|
|
#endif
|
2017-12-21 02:13:23 +00:00
|
|
|
|
2020-05-16 02:03:29 +00:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
static void _editor_init_callback() {
|
|
|
|
EditorDebuggerServer::register_protocol_handler("ws://", EditorDebuggerServerWebSocket::create);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-05-03 09:56:08 +00:00
|
|
|
void initialize_websocket_module(ModuleInitializationLevel p_level) {
|
|
|
|
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
|
2017-12-21 02:13:23 +00:00
|
|
|
#ifdef JAVASCRIPT_ENABLED
|
2022-05-03 09:56:08 +00:00
|
|
|
EMWSPeer::make_default();
|
|
|
|
EMWSClient::make_default();
|
|
|
|
EMWSServer::make_default();
|
2017-12-21 02:13:23 +00:00
|
|
|
#else
|
2022-05-03 09:56:08 +00:00
|
|
|
WSLPeer::make_default();
|
|
|
|
WSLClient::make_default();
|
|
|
|
WSLServer::make_default();
|
2017-12-21 02:13:23 +00:00
|
|
|
#endif
|
|
|
|
|
2022-05-03 09:56:08 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(WebSocketMultiplayerPeer);
|
|
|
|
ClassDB::register_custom_instance_class<WebSocketServer>();
|
|
|
|
ClassDB::register_custom_instance_class<WebSocketClient>();
|
|
|
|
ClassDB::register_custom_instance_class<WebSocketPeer>();
|
|
|
|
}
|
2020-03-16 16:02:14 +00:00
|
|
|
|
|
|
|
#ifdef TOOLS_ENABLED
|
2022-05-03 09:56:08 +00:00
|
|
|
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
|
|
|
EditorNode::add_init_callback(&_editor_init_callback);
|
|
|
|
}
|
2020-03-16 16:02:14 +00:00
|
|
|
#endif
|
2017-12-21 02:13:23 +00:00
|
|
|
}
|
|
|
|
|
2022-05-03 09:56:08 +00:00
|
|
|
void uninitialize_websocket_module(ModuleInitializationLevel p_level) {
|
|
|
|
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|