mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
[Net] Drop is_connected_to_host for TCP and UDP.
The UDP method is now called `is_socket_connected` to limit confusion with the actual host connection status which doesn't make sense in UDP. The TCP method is completly dropped, use get_status instead. The only one left is the WebSocketPeer one, which should be fine as is for now.
This commit is contained in:
parent
0e52867668
commit
331f1662df
8 changed files with 8 additions and 20 deletions
|
|
@ -184,7 +184,7 @@ Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool
|
|||
}
|
||||
|
||||
Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool p_block) {
|
||||
if (!is_connected_to_host()) {
|
||||
if (status != STATUS_CONNECTED) {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
|
@ -237,14 +237,10 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool
|
|||
}
|
||||
|
||||
void StreamPeerTCP::set_no_delay(bool p_enabled) {
|
||||
ERR_FAIL_COND(!is_connected_to_host());
|
||||
ERR_FAIL_COND(!_sock.is_valid() || !_sock->is_open());
|
||||
_sock->set_tcp_no_delay_enabled(p_enabled);
|
||||
}
|
||||
|
||||
bool StreamPeerTCP::is_connected_to_host() const {
|
||||
return _sock.is_valid() && _sock->is_open() && (status == STATUS_CONNECTED || status == STATUS_CONNECTING);
|
||||
}
|
||||
|
||||
StreamPeerTCP::Status StreamPeerTCP::get_status() const {
|
||||
return status;
|
||||
}
|
||||
|
|
@ -319,7 +315,6 @@ Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
|
|||
void StreamPeerTCP::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("bind", "port", "host"), &StreamPeerTCP::bind, DEFVAL("*"));
|
||||
ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port"), &StreamPeerTCP::_connect);
|
||||
ClassDB::bind_method(D_METHOD("is_connected_to_host"), &StreamPeerTCP::is_connected_to_host);
|
||||
ClassDB::bind_method(D_METHOD("poll"), &StreamPeerTCP::poll);
|
||||
ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerTCP::get_status);
|
||||
ClassDB::bind_method(D_METHOD("get_connected_host"), &StreamPeerTCP::get_connected_host);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue