summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-11-12 11:23:23 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-11-12 11:23:23 -0300
commit6dd8768811cfca5bb831619d93cf870e5d20667f (patch)
tree9e8837b7c8334855a1bce1bd79ab441edde28129 /core
parentc8cd5222a7fa931f072e02b23c5b9d826d0ef548 (diff)
3D Import Import & UDP
-=-=-=-=-=-=-=-=-=-=- -Animation Import filter support -Animation Clip import support -Animation Optimizer Fixes, Improvements and Visibile Options -Extremely Experimental UDP support.
Diffstat (limited to 'core')
-rw-r--r--core/io/packet_peer.cpp2
-rw-r--r--core/io/packet_peer_udp.cpp48
-rw-r--r--core/io/packet_peer_udp.h35
-rw-r--r--core/register_core_types.cpp2
4 files changed, 86 insertions, 1 deletions
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 37fc9c4a0a..b566ce4b7b 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -111,7 +111,7 @@ Variant PacketPeer::_bnd_get_var() const {
void PacketPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_var"),&PacketPeer::_bnd_get_var);
- ObjectTypeDB::bind_method(_MD("put_var", "var:Variant"),&PacketPeer::put_var);
+ ObjectTypeDB::bind_method(_MD("put_var", "var:var"),&PacketPeer::put_var);
ObjectTypeDB::bind_method(_MD("get_available_packet_count"),&PacketPeer::get_available_packet_count);
};
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
new file mode 100644
index 0000000000..60f56ed28a
--- /dev/null
+++ b/core/io/packet_peer_udp.cpp
@@ -0,0 +1,48 @@
+#include "packet_peer_udp.h"
+
+
+
+PacketPeerUDP* (*PacketPeerUDP::_create)()=NULL;
+
+int PacketPeerUDP::_get_packet_address() const {
+
+ IP_Address ip = get_packet_address();
+ return ip.host;
+}
+
+String PacketPeerUDP::_get_packet_ip() const {
+
+ return get_packet_address();
+}
+
+
+void PacketPeerUDP::_bind_methods() {
+
+ 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("poll:Error"),&PacketPeerUDP::poll);
+ ObjectTypeDB::bind_method(_MD("is_listening"),&PacketPeerUDP::is_listening);
+ ObjectTypeDB::bind_method(_MD("get_packet_ip"),&PacketPeerUDP::_get_packet_ip);
+ ObjectTypeDB::bind_method(_MD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
+ ObjectTypeDB::bind_method(_MD("set_send_address","address","port"),&PacketPeerUDP::set_send_address);
+
+
+}
+
+Ref<PacketPeerUDP> PacketPeerUDP::create_ref() {
+
+ if (!_create)
+ return Ref<PacketPeerUDP>();
+ return Ref<PacketPeerUDP>(_create());
+}
+
+PacketPeerUDP* PacketPeerUDP::create() {
+
+ if (!_create)
+ return NULL;
+ return _create();
+}
+
+PacketPeerUDP::PacketPeerUDP()
+{
+}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
new file mode 100644
index 0000000000..049ac0132f
--- /dev/null
+++ b/core/io/packet_peer_udp.h
@@ -0,0 +1,35 @@
+#ifndef PACKET_PEER_UDP_H
+#define PACKET_PEER_UDP_H
+
+
+#include "io/packet_peer.h"
+
+class PacketPeerUDP : public PacketPeer {
+ OBJ_TYPE(PacketPeerUDP,PacketPeer);
+
+protected:
+
+ static PacketPeerUDP* (*_create)();
+ static void _bind_methods();
+
+ int _get_packet_address() const;
+ String _get_packet_ip() const;
+
+public:
+
+ virtual Error listen(int p_port,int p_recv_buffer_size=65536)=0;
+ virtual void close()=0;
+ virtual Error poll()=0;
+ virtual bool is_listening() const=0;
+ virtual IP_Address get_packet_address() const=0;
+ virtual int get_packet_port() const=0;
+ virtual void set_send_address(const IP_Address& p_address,int p_port)=0;
+
+
+ static Ref<PacketPeerUDP> create_ref();
+ static PacketPeerUDP* create();
+
+ PacketPeerUDP();
+};
+
+#endif // PACKET_PEER_UDP_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 492068f604..2f16e31de6 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -29,6 +29,7 @@
#include "register_core_types.h"
#include "io/tcp_server.h"
+#include "io/packet_peer_udp.h"
#include "io/config_file.h"
#include "os/main_loop.h"
#include "io/packet_peer.h"
@@ -115,6 +116,7 @@ void register_core_types() {
ObjectTypeDB::register_virtual_type<StreamPeer>();
ObjectTypeDB::register_create_type<StreamPeerTCP>();
ObjectTypeDB::register_create_type<TCP_Server>();
+ ObjectTypeDB::register_create_type<PacketPeerUDP>();
ObjectTypeDB::register_create_type<StreamPeerSSL>();
ObjectTypeDB::register_virtual_type<IP>();
ObjectTypeDB::register_virtual_type<PacketPeer>();