summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/http_client.cpp4
-rw-r--r--core/io/http_client.h1
-rw-r--r--core/io/packet_peer_udp.cpp6
-rw-r--r--core/io/packet_peer_udp.h1
-rw-r--r--core/io/stream_peer_tcp.cpp6
-rw-r--r--core/io/stream_peer_tcp.h1
-rw-r--r--core/io/tcp_server.cpp6
-rw-r--r--core/io/tcp_server.h1
-rw-r--r--scene/main/http_request.cpp4
-rw-r--r--scene/main/http_request.h1
10 files changed, 31 insertions, 0 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index c9c674d4f0..24314e3a1a 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -29,6 +29,10 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
+void HTTPClient::set_ip_type(IP::Type p_type) {
+ tcp_connection->set_ip_type(p_type);
+}
+
Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host, IP::Type p_addr_type){
close();
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 34812616dd..7ec418fd23 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -164,6 +164,7 @@ private:
public:
+ virtual void set_ip_type(IP::Type p_type);
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true, IP::Type p_addr_type = IP::TYPE_ANY);
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index dadef8a6f4..d04371f4fc 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -51,8 +51,14 @@ Error PacketPeerUDP::_set_send_address(const String& p_address, int p_port) {
return OK;
}
+void PacketPeerUDP::set_ip_type(IP::Type p_type) {
+ close();
+ ip_type = p_type;
+}
+
void PacketPeerUDP::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&PacketPeerUDP::set_ip_type);
ObjectTypeDB::bind_method(_MD("listen:Error","port", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(65536));
ObjectTypeDB::bind_method(_MD("close"),&PacketPeerUDP::close);
ObjectTypeDB::bind_method(_MD("wait:Error"),&PacketPeerUDP::wait);
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 821007a628..600d4c4682 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -49,6 +49,7 @@ protected:
public:
+ virtual void set_ip_type(IP::Type p_type);
virtual Error listen(int p_port, int p_recv_buffer_size=65536)=0;
virtual void close()=0;
virtual Error wait()=0;
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index d374f54a8a..6c26dbb89e 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -45,8 +45,14 @@ Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
return OK;
}
+void StreamPeerTCP::set_ip_type(IP::Type p_type) {
+ disconnect();
+ ip_type = p_type;
+}
+
void StreamPeerTCP::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&StreamPeerTCP::set_ip_type);
ObjectTypeDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::_connect);
ObjectTypeDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected);
ObjectTypeDB::bind_method(_MD("get_status"),&StreamPeerTCP::get_status);
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index f44784d2b5..2408f4cdf5 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -59,6 +59,7 @@ protected:
public:
+ virtual void set_ip_type(IP::Type p_type);
virtual Error connect(const IP_Address& p_host, uint16_t p_port)=0;
//read/write from streampeer
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 0dcec8001e..5f3f74131d 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -54,8 +54,14 @@ Error TCP_Server::_listen(uint16_t p_port, DVector<String> p_accepted_hosts) {
}
+void TCP_Server::set_ip_type(IP::Type p_type) {
+ stop();
+ ip_type = p_type;
+}
+
void TCP_Server::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&TCP_Server::set_ip_type);
ObjectTypeDB::bind_method(_MD("listen","port","accepted_hosts"),&TCP_Server::_listen,DEFVAL(DVector<String>()));
ObjectTypeDB::bind_method(_MD("is_connection_available"),&TCP_Server::is_connection_available);
ObjectTypeDB::bind_method(_MD("take_connection"),&TCP_Server::take_connection);
diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h
index aef62eb715..5b8b40b704 100644
--- a/core/io/tcp_server.h
+++ b/core/io/tcp_server.h
@@ -47,6 +47,7 @@ protected:
static void _bind_methods();
public:
+ virtual void set_ip_type(IP::Type p_type);
virtual Error listen(uint16_t p_port, const List<String> *p_accepted_hosts=NULL)=0;
virtual bool is_connection_available() const=0;
virtual Ref<StreamPeerTCP> take_connection()=0;
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 4b6cbde859..4667812312 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -28,6 +28,10 @@
/*************************************************************************/
#include "http_request.h"
+void HTTPRequest::set_ip_type(IP::Type p_type) {
+ client->set_ip_type(p_type);
+}
+
void HTTPRequest::_redirect_request(const String& p_new_url) {
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 705799f044..4dd79234b0 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -116,6 +116,7 @@ protected:
static void _bind_methods();
public:
+ virtual void set_ip_type(IP::Type p_type);
Error request(const String& p_url, const Vector<String>& p_custom_headers=Vector<String>(), bool p_ssl_validate_domain=true, HTTPClient::Method p_method=HTTPClient::METHOD_GET, const String& p_request_data=""); //connects to a full url and perform request
void cancel_request();
HTTPClient::Status get_http_client_status() const;