diff options
Diffstat (limited to 'src/udp_wrap.cc')
-rw-r--r-- | src/udp_wrap.cc | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 39ab750215..b0f8bad1f8 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -24,6 +24,7 @@ #include "slab_allocator.h" #include "req_wrap.h" #include "handle_wrap.h" +#include "udp_wrap.h" #include <stdlib.h> @@ -60,45 +61,6 @@ static Persistent<String> onmessage_sym; static SlabAllocator slab_allocator(SLAB_SIZE); -class UDPWrap: public HandleWrap { -public: - static void Initialize(Handle<Object> target); - static Handle<Value> New(const Arguments& args); - static Handle<Value> Bind(const Arguments& args); - static Handle<Value> Send(const Arguments& args); - static Handle<Value> Bind6(const Arguments& args); - static Handle<Value> Send6(const Arguments& args); - static Handle<Value> RecvStart(const Arguments& args); - static Handle<Value> RecvStop(const Arguments& args); - static Handle<Value> GetSockName(const Arguments& args); - static Handle<Value> AddMembership(const Arguments& args); - static Handle<Value> DropMembership(const Arguments& args); - static Handle<Value> SetMulticastTTL(const Arguments& args); - static Handle<Value> SetMulticastLoopback(const Arguments& args); - static Handle<Value> SetBroadcast(const Arguments& args); - static Handle<Value> SetTTL(const Arguments& args); - -private: - UDPWrap(Handle<Object> object); - virtual ~UDPWrap(); - - static Handle<Value> DoBind(const Arguments& args, int family); - static Handle<Value> DoSend(const Arguments& args, int family); - static Handle<Value> SetMembership(const Arguments& args, - uv_membership membership); - - static uv_buf_t OnAlloc(uv_handle_t* handle, size_t suggested_size); - static void OnSend(uv_udp_send_t* req, int status); - static void OnRecv(uv_udp_t* handle, - ssize_t nread, - uv_buf_t buf, - struct sockaddr* addr, - unsigned flags); - - uv_udp_t handle_; -}; - - UDPWrap::UDPWrap(Handle<Object> object): HandleWrap(object, (uv_handle_t*)&handle_) { int r = uv_udp_init(uv_default_loop(), &handle_); @@ -426,6 +388,18 @@ void UDPWrap::OnRecv(uv_udp_t* handle, } +UDPWrap* UDPWrap::Unwrap(Local<Object> obj) { + assert(!obj.IsEmpty()); + assert(obj->InternalFieldCount() > 0); + return static_cast<UDPWrap*>(obj->GetPointerFromInternalField(0)); +} + + +uv_udp_t* UDPWrap::UVHandle() { + return &handle_; +} + + } // namespace node NODE_MODULE(node_udp_wrap, node::UDPWrap::Initialize) |