diff options
Diffstat (limited to 'core/io/packet_peer_udp.cpp')
-rw-r--r-- | core/io/packet_peer_udp.cpp | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index 8b6bd7ef90..0640d56c47 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -33,7 +33,6 @@ #include "core/io/ip.h" void PacketPeerUDP::set_blocking_mode(bool p_enable) { - blocking = p_enable; } @@ -44,7 +43,6 @@ void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) { } Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_if_name) { - ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); ERR_FAIL_COND_V(!p_multi_address.is_valid(), ERR_INVALID_PARAMETER); @@ -59,19 +57,16 @@ Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_i } Error PacketPeerUDP::leave_multicast_group(IP_Address p_multi_address, String p_if_name) { - ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); ERR_FAIL_COND_V(!_sock->is_open(), ERR_UNCONFIGURED); return _sock->leave_multicast_group(p_multi_address, p_if_name); } String PacketPeerUDP::_get_packet_ip() const { - return get_packet_address(); } Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) { - IP_Address ip; if (p_address.is_valid_ip_address()) { ip = p_address; @@ -86,7 +81,6 @@ Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) { } int PacketPeerUDP::get_available_packet_count() const { - // TODO we should deprecate this, and expose poll instead! Error err = const_cast<PacketPeerUDP *>(this)->_poll(); if (err != OK) @@ -96,7 +90,6 @@ int PacketPeerUDP::get_available_packet_count() const { } Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - Error err = _poll(); if (err != OK) return err; @@ -117,7 +110,6 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { } Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); ERR_FAIL_COND_V(!peer_addr.is_valid(), ERR_UNCONFIGURED); @@ -154,12 +146,10 @@ Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) { } int PacketPeerUDP::get_max_packet_size() const { - return 512; // uhm maybe not } Error PacketPeerUDP::listen(int p_port, const IP_Address &p_bind_address, int p_recv_buffer_size) { - ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER); @@ -245,7 +235,6 @@ bool PacketPeerUDP::is_connected_to_host() const { } void PacketPeerUDP::close() { - if (_sock.is_valid()) _sock->close(); rb.resize(16); @@ -254,13 +243,11 @@ void PacketPeerUDP::close() { } Error PacketPeerUDP::wait() { - ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); return _sock->poll(NetSocket::POLL_TYPE_IN, -1); } Error PacketPeerUDP::_poll() { - ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); if (!_sock->is_open()) { @@ -305,29 +292,24 @@ Error PacketPeerUDP::_poll() { return OK; } bool PacketPeerUDP::is_listening() const { - return _sock.is_valid() && _sock->is_open(); } IP_Address PacketPeerUDP::get_packet_address() const { - return packet_ip; } int PacketPeerUDP::get_packet_port() const { - return packet_port; } void PacketPeerUDP::set_dest_address(const IP_Address &p_address, int p_port) { - ERR_FAIL_COND_MSG(connected, "Destination address cannot be set for connected sockets"); peer_addr = p_address; peer_port = p_port; } void PacketPeerUDP::_bind_methods() { - ClassDB::bind_method(D_METHOD("listen", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536)); ClassDB::bind_method(D_METHOD("close"), &PacketPeerUDP::close); ClassDB::bind_method(D_METHOD("wait"), &PacketPeerUDP::wait); @@ -348,6 +330,5 @@ PacketPeerUDP::PacketPeerUDP() : } PacketPeerUDP::~PacketPeerUDP() { - close(); } |