mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-03 23:21:15 +00:00 
			
		
		
		
	Display set_nodelay to GDScript
Pass enabled arg
Rename set_nodelay to set_no_delay
Add description to the method
Change description
(cherry picked from commit 87adf9cfba)
			
			
This commit is contained in:
		
							parent
							
								
									ef49c166f6
								
							
						
					
					
						commit
						5481ece976
					
				
					 9 changed files with 18 additions and 7 deletions
				
			
		| 
						 | 
					@ -83,7 +83,7 @@ int64_t FileAccessNetworkClient::get_64() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void FileAccessNetworkClient::_thread_func() {
 | 
					void FileAccessNetworkClient::_thread_func() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	client->set_nodelay(true);
 | 
						client->set_no_delay(true);
 | 
				
			||||||
	while (!quit) {
 | 
						while (!quit) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		DEBUG_PRINT("SEM WAIT - " + itos(sem->get()));
 | 
							DEBUG_PRINT("SEM WAIT - " + itos(sem->get()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,6 +55,7 @@ void StreamPeerTCP::_bind_methods() {
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("get_connected_host"), &StreamPeerTCP::get_connected_host);
 | 
						ClassDB::bind_method(D_METHOD("get_connected_host"), &StreamPeerTCP::get_connected_host);
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("get_connected_port"), &StreamPeerTCP::get_connected_port);
 | 
						ClassDB::bind_method(D_METHOD("get_connected_port"), &StreamPeerTCP::get_connected_port);
 | 
				
			||||||
	ClassDB::bind_method(D_METHOD("disconnect_from_host"), &StreamPeerTCP::disconnect_from_host);
 | 
						ClassDB::bind_method(D_METHOD("disconnect_from_host"), &StreamPeerTCP::disconnect_from_host);
 | 
				
			||||||
 | 
						ClassDB::bind_method(D_METHOD("set_no_delay", "enabled"), &StreamPeerTCP::set_no_delay);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIND_ENUM_CONSTANT(STATUS_NONE);
 | 
						BIND_ENUM_CONSTANT(STATUS_NONE);
 | 
				
			||||||
	BIND_ENUM_CONSTANT(STATUS_CONNECTING);
 | 
						BIND_ENUM_CONSTANT(STATUS_CONNECTING);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,7 +65,7 @@ public:
 | 
				
			||||||
	virtual void disconnect_from_host() = 0;
 | 
						virtual void disconnect_from_host() = 0;
 | 
				
			||||||
	virtual IP_Address get_connected_host() const = 0;
 | 
						virtual IP_Address get_connected_host() const = 0;
 | 
				
			||||||
	virtual uint16_t get_connected_port() const = 0;
 | 
						virtual uint16_t get_connected_port() const = 0;
 | 
				
			||||||
	virtual void set_nodelay(bool p_enabled) = 0;
 | 
						virtual void set_no_delay(bool p_enabled) = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static Ref<StreamPeerTCP> create_ref();
 | 
						static Ref<StreamPeerTCP> create_ref();
 | 
				
			||||||
	static StreamPeerTCP *create();
 | 
						static StreamPeerTCP *create();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,16 @@
 | 
				
			||||||
				Disconnect from host.
 | 
									Disconnect from host.
 | 
				
			||||||
			</description>
 | 
								</description>
 | 
				
			||||||
		</method>
 | 
							</method>
 | 
				
			||||||
 | 
							<method name="set_no_delay">
 | 
				
			||||||
 | 
								<return type="void">
 | 
				
			||||||
 | 
								</return>
 | 
				
			||||||
 | 
								<argument index="0" name="enabled" type="bool">
 | 
				
			||||||
 | 
								</argument>
 | 
				
			||||||
 | 
								<description>
 | 
				
			||||||
 | 
									Disable Nagle algorithm to improve latency for small packets.
 | 
				
			||||||
 | 
									Note that for applications that send large packets, or need to transfer a lot of data, this can reduce total bandwidth.
 | 
				
			||||||
 | 
								</description>
 | 
				
			||||||
 | 
							</method>
 | 
				
			||||||
		<method name="get_connected_host" qualifiers="const">
 | 
							<method name="get_connected_host" qualifiers="const">
 | 
				
			||||||
			<return type="String">
 | 
								<return type="String">
 | 
				
			||||||
			</return>
 | 
								</return>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -304,7 +304,7 @@ Error StreamPeerTCPPosix::read(uint8_t *p_buffer, int p_bytes, int &r_received,
 | 
				
			||||||
	return OK;
 | 
						return OK;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void StreamPeerTCPPosix::set_nodelay(bool p_enabled) {
 | 
					void StreamPeerTCPPosix::set_no_delay(bool p_enabled) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_FAIL_COND(!is_connected_to_host());
 | 
						ERR_FAIL_COND(!is_connected_to_host());
 | 
				
			||||||
	int flag = p_enabled ? 1 : 0;
 | 
						int flag = p_enabled ? 1 : 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,7 +77,7 @@ public:
 | 
				
			||||||
	virtual Status get_status() const;
 | 
						virtual Status get_status() const;
 | 
				
			||||||
	virtual void disconnect_from_host();
 | 
						virtual void disconnect_from_host();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void set_nodelay(bool p_enabled);
 | 
						virtual void set_no_delay(bool p_enabled);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static void make_default();
 | 
						static void make_default();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -332,7 +332,7 @@ Error StreamPeerTCPWinsock::connect_to_host(const IP_Address &p_host, uint16_t p
 | 
				
			||||||
	return OK;
 | 
						return OK;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void StreamPeerTCPWinsock::set_nodelay(bool p_enabled) {
 | 
					void StreamPeerTCPWinsock::set_no_delay(bool p_enabled) {
 | 
				
			||||||
	ERR_FAIL_COND(!is_connected_to_host());
 | 
						ERR_FAIL_COND(!is_connected_to_host());
 | 
				
			||||||
	int flag = p_enabled ? 1 : 0;
 | 
						int flag = p_enabled ? 1 : 0;
 | 
				
			||||||
	setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
 | 
						setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,7 @@ public:
 | 
				
			||||||
	static void make_default();
 | 
						static void make_default();
 | 
				
			||||||
	static void cleanup();
 | 
						static void cleanup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	virtual void set_nodelay(bool p_enabled);
 | 
						virtual void set_no_delay(bool p_enabled);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	StreamPeerTCPWinsock();
 | 
						StreamPeerTCPWinsock();
 | 
				
			||||||
	~StreamPeerTCPWinsock();
 | 
						~StreamPeerTCPWinsock();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ void EditorFileServer::_subthread_start(void *s) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ClientData *cd = (ClientData *)s;
 | 
						ClientData *cd = (ClientData *)s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cd->connection->set_nodelay(true);
 | 
						cd->connection->set_no_delay(true);
 | 
				
			||||||
	uint8_t buf4[8];
 | 
						uint8_t buf4[8];
 | 
				
			||||||
	Error err = cd->connection->get_data(buf4, 4);
 | 
						Error err = cd->connection->get_data(buf4, 4);
 | 
				
			||||||
	if (err != OK) {
 | 
						if (err != OK) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue