2017-12-21 03:13:23 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* register_types.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
2017-12-21 03:47:16 +01:00
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
2017-12-21 03:13:23 +01:00
|
|
|
/*************************************************************************/
|
2021-01-01 20:13:46 +01:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-12-21 03:13:23 +01: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 12:46:36 +01:00
|
|
|
|
2017-12-21 03:13:23 +01:00
|
|
|
#include "register_types.h"
|
2020-11-07 23:33:38 +01:00
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/error/error_macros.h"
|
2017-12-21 03:13:23 +01:00
|
|
|
#ifdef JAVASCRIPT_ENABLED
|
|
|
|
#include "emscripten.h"
|
|
|
|
#include "emws_client.h"
|
|
|
|
#include "emws_peer.h"
|
|
|
|
#include "emws_server.h"
|
|
|
|
#else
|
2019-06-24 15:46:24 +02:00
|
|
|
#include "wsl_client.h"
|
|
|
|
#include "wsl_server.h"
|
2017-12-21 03:13:23 +01:00
|
|
|
#endif
|
2020-03-16 17:02:14 +01:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
#include "editor/debugger/editor_debugger_server.h"
|
2020-05-16 04:03:29 +02:00
|
|
|
#include "editor/editor_node.h"
|
2020-03-16 17:02:14 +01:00
|
|
|
#include "editor_debugger_server_websocket.h"
|
|
|
|
#endif
|
2017-12-21 03:13:23 +01:00
|
|
|
|
2020-05-16 04:03:29 +02:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
static void _editor_init_callback() {
|
|
|
|
EditorDebuggerServer::register_protocol_handler("ws://", EditorDebuggerServerWebSocket::create);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-12-21 03:13:23 +01:00
|
|
|
void register_websocket_types() {
|
|
|
|
#ifdef JAVASCRIPT_ENABLED
|
|
|
|
EMWSPeer::make_default();
|
|
|
|
EMWSClient::make_default();
|
|
|
|
EMWSServer::make_default();
|
|
|
|
#else
|
2019-07-01 18:14:26 +02:00
|
|
|
WSLPeer::make_default();
|
2019-06-24 15:46:24 +02:00
|
|
|
WSLClient::make_default();
|
|
|
|
WSLServer::make_default();
|
2017-12-21 03:13:23 +01:00
|
|
|
#endif
|
|
|
|
|
2021-07-12 00:30:33 +02:00
|
|
|
GDREGISTER_VIRTUAL_CLASS(WebSocketMultiplayerPeer);
|
2017-12-21 03:13:23 +01:00
|
|
|
ClassDB::register_custom_instance_class<WebSocketServer>();
|
|
|
|
ClassDB::register_custom_instance_class<WebSocketClient>();
|
|
|
|
ClassDB::register_custom_instance_class<WebSocketPeer>();
|
2020-03-16 17:02:14 +01:00
|
|
|
|
|
|
|
#ifdef TOOLS_ENABLED
|
2020-05-16 04:03:29 +02:00
|
|
|
EditorNode::add_init_callback(&_editor_init_callback);
|
2020-03-16 17:02:14 +01:00
|
|
|
#endif
|
2017-12-21 03:13:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void unregister_websocket_types() {}
|