1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Implement TCP Server bind address

(cherry picked from commit b2839343ca)
This commit is contained in:
Fabio Alessandrelli
2017-01-18 08:37:24 +01:00
parent 90a747a52d
commit 43d992fc34
9 changed files with 49 additions and 29 deletions

View File

@@ -44,15 +44,6 @@ TCP_Server *TCP_Server::create() {
return _create();
}
Error TCP_Server::_listen(uint16_t p_port, DVector<String> p_accepted_hosts) {
List<String> hosts;
for (int i = 0; i < p_accepted_hosts.size(); i++)
hosts.push_back(p_accepted_hosts.get(i));
return listen(p_port, hosts.size() ? &hosts : NULL);
}
void TCP_Server::set_ip_type(IP::Type p_type) {
stop();
ip_type = p_type;
@@ -61,7 +52,7 @@ void TCP_Server::set_ip_type(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("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ObjectTypeDB::bind_method(_MD("is_connection_available"), &TCP_Server::is_connection_available);
ObjectTypeDB::bind_method(_MD("take_connection"), &TCP_Server::take_connection);
ObjectTypeDB::bind_method(_MD("stop"), &TCP_Server::stop);