1 /*************************************************************************/ 2 /* networked_multiplayer_peer.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ 10 /* */ 11 /* Permission is hereby granted, free of charge, to any person obtaining */ 12 /* a copy of this software and associated documentation files (the */ 13 /* "Software"), to deal in the Software without restriction, including */ 14 /* without limitation the rights to use, copy, modify, merge, publish, */ 15 /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 /* permit persons to whom the Software is furnished to do so, subject to */ 17 /* the following conditions: */ 18 /* */ 19 /* The above copyright notice and this permission notice shall be */ 20 /* included in all copies or substantial portions of the Software. */ 21 /* */ 22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 /*************************************************************************/ 30 31 #ifndef NETWORKED_MULTIPLAYER_PEER_H 32 #define NETWORKED_MULTIPLAYER_PEER_H 33 34 #include "core/io/packet_peer.h" 35 36 class NetworkedMultiplayerPeer : public PacketPeer { 37 38 GDCLASS(NetworkedMultiplayerPeer, PacketPeer); 39 40 protected: 41 static void _bind_methods(); 42 43 public: 44 enum { 45 TARGET_PEER_BROADCAST = 0, 46 TARGET_PEER_SERVER = 1 47 }; 48 enum TransferMode { 49 TRANSFER_MODE_UNRELIABLE, 50 TRANSFER_MODE_UNRELIABLE_ORDERED, 51 TRANSFER_MODE_RELIABLE, 52 }; 53 54 enum ConnectionStatus { 55 CONNECTION_DISCONNECTED, 56 CONNECTION_CONNECTING, 57 CONNECTION_CONNECTED, 58 }; 59 60 virtual void set_transfer_mode(TransferMode p_mode) = 0; 61 virtual TransferMode get_transfer_mode() const = 0; 62 virtual void set_target_peer(int p_peer_id) = 0; 63 64 virtual int get_packet_peer() const = 0; 65 66 virtual bool is_server() const = 0; 67 68 virtual void poll() = 0; 69 70 virtual int get_unique_id() const = 0; 71 72 virtual void set_refuse_new_connections(bool p_enable) = 0; 73 virtual bool is_refusing_new_connections() const = 0; 74 75 virtual ConnectionStatus get_connection_status() const = 0; 76 77 NetworkedMultiplayerPeer(); 78 }; 79 80 VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode) 81 VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::ConnectionStatus) 82 83 #endif // NetworkedMultiplayerPeer_H 84