Allow setting ip_type for TCP/UDP and HTTP classes
This commit is contained in:
parent
c18c5013f8
commit
a77a0118f6
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue