mirror of
https://github.com/godotengine/godot
synced 2024-09-05 12:18:25 +00:00
add NetworkedMultiplayerENet::set_bind_ip
which allows ENet to bind on custom IP.
This commit is contained in:
parent
d015d93b8f
commit
8a4e636df6
|
@ -26,7 +26,7 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int
|
|||
ERR_FAIL_COND_V(active,ERR_ALREADY_IN_USE);
|
||||
|
||||
ENetAddress address;
|
||||
address.host = ENET_HOST_ANY;
|
||||
address.host = bind_ip;
|
||||
|
||||
address.port = p_port;
|
||||
|
||||
|
@ -610,12 +610,12 @@ void NetworkedMultiplayerENet::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("close_connection"),&NetworkedMultiplayerENet::close_connection);
|
||||
ObjectTypeDB::bind_method(_MD("set_compression_mode","mode"),&NetworkedMultiplayerENet::set_compression_mode);
|
||||
ObjectTypeDB::bind_method(_MD("get_compression_mode"),&NetworkedMultiplayerENet::get_compression_mode);
|
||||
ObjectTypeDB::bind_method(_MD("set_bind_ip", "ip"),&NetworkedMultiplayerENet::set_bind_ip);
|
||||
|
||||
BIND_CONSTANT( COMPRESS_NONE );
|
||||
BIND_CONSTANT( COMPRESS_RANGE_CODER );
|
||||
BIND_CONSTANT( COMPRESS_FASTLZ );
|
||||
BIND_CONSTANT( COMPRESS_ZLIB );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -635,9 +635,16 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet(){
|
|||
enet_compressor.decompress=enet_decompress;
|
||||
enet_compressor.destroy=enet_compressor_destroy;
|
||||
|
||||
bind_ip=ENET_HOST_ANY;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerENet::~NetworkedMultiplayerENet(){
|
||||
|
||||
close_connection();
|
||||
}
|
||||
|
||||
// sets IP for ENet to bind when using create_server
|
||||
// if no IP is set, then ENet bind to ENET_HOST_ANY
|
||||
void NetworkedMultiplayerENet::set_bind_ip(const IP_Address& p_ip){
|
||||
bind_ip=p_ip.host;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ private:
|
|||
static void enet_compressor_destroy(void * context);
|
||||
void _setup_compressor();
|
||||
|
||||
enet_uint32 bind_ip;
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
@ -103,6 +104,8 @@ public:
|
|||
|
||||
NetworkedMultiplayerENet();
|
||||
~NetworkedMultiplayerENet();
|
||||
|
||||
void set_bind_ip(const IP_Address& p_ip);
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(NetworkedMultiplayerENet::CompressionMode);
|
||||
|
|
Loading…
Reference in a new issue