This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This means that we always need to use `DeleteFnPtr` to make sure that the timer is actually cleaned up, but I guess that’s an acceptable restriction for now.
- Loading branch information
Showing
3 changed files
with
97 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include "udp_wrap.h" | ||
|
||
namespace node { | ||
|
||
class JSUDPWrap final : public UDPWrapBase, public AsyncWrap { | ||
public: | ||
JSUDPWrap(Environment* env, Local<Object> obj); | ||
|
||
static void New(const FunctionCallbackInfo<Value>& args); | ||
static void Receive(const FunctionCallbackInfo<Value>& args); | ||
static void CreateSendWrap(const FunctionCallbackInfo<Value>& args); | ||
static void SendDone(const FunctionCallbackInfo<Value>& args); | ||
static void AfterBind(const FunctionCallbackInfo<Value>& args); | ||
|
||
int RecvStart() override; | ||
int RecvStop() override; | ||
ssize_t Send(uv_buf_t* bufs, | ||
size_t nbufs, | ||
const sockaddr* addr) override; | ||
int GetPeerName(sockaddr* name, int* namelen) override; | ||
int GetSockName(sockaddr* name, int* namelen) override; | ||
AsyncWrap* GetAsyncWrap() override; | ||
|
||
static void Initialize(Local<Object> target, | ||
Local<Value> unused, | ||
Local<Context> context, | ||
void* priv); | ||
}; | ||
|
||
JSUDPWrap::JSUDPWrap(Environment* env, Local<Object> obj) { | ||
} | ||
|
||
void JSUDPWrap::New(const FunctionCallbackInfo<Value>& args) { | ||
} | ||
|
||
void JSUDPWrap::Receive(const FunctionCallbackInfo<Value>& args) { | ||
} | ||
|
||
void JSUDPWrap::CreateSendWrap(const FunctionCallbackInfo<Value>& args) { | ||
} | ||
|
||
void JSUDPWrap::SendDone(const FunctionCallbackInfo<Value>& args) { | ||
} | ||
|
||
void JSUDPWrap::AfterBind(const FunctionCallbackInfo<Value>& args) { | ||
} | ||
|
||
int JSUDPWrap::RecvStart() override { | ||
} | ||
|
||
int JSUDPWrap::RecvStop() override { | ||
} | ||
|
||
ssize_t JSUDPWrap::Send(uv_buf_t* bufs, | ||
size_t nbufs, | ||
const sockaddr* addr) override { | ||
} | ||
|
||
int JSUDPWrap::GetPeerName(sockaddr* name, int* namelen) override { | ||
} | ||
|
||
int JSUDPWrap::GetSockName(sockaddr* name, int* namelen) override { | ||
} | ||
|
||
AsyncWrap* JSUDPWrap::GetAsyncWrap() override { | ||
return this; | ||
} | ||
|
||
void JSUDPWrap::Initialize(Local<Object> target, | ||
Local<Value> unused, | ||
Local<Context> context, | ||
void* priv) { | ||
Environment* env = Environment::GetCurrent(context); | ||
Local<FunctionTemplate> t = env->NewFunctionTemplate(New); | ||
t->InstanceTemplate()->SetInternalFieldCount(kUDPWrapBaseField + 1); | ||
Local<String> js_udp_string = | ||
FIXED_ONE_BYTE_STRING(env->isolate(), "JSUDPWrap"); | ||
t->SetClassName(js_udp_string); | ||
|
||
env->SetProtoMethod(t, "receive", Receive); | ||
env->SetProtoMethod(t, "createSendWrap", CreateSendWrap); | ||
env->SetProtoMethod(t, "sendDone", SendDone); | ||
env->SetProtoMethod(t, "afterBind", AfterBind); | ||
|
||
t->Inherit(HandleWrap::GetConstructorTemplate(env)); | ||
|
||
target->Set(env->context(), | ||
js_udp_string, | ||
t->GetFunction(env->context()).ToLocalChecked()).Check(); | ||
} | ||
|
||
} // namespace node | ||
|
||
NODE_MODULE_CONTEXT_AWARE_INTERNAL(js_udp_wrap, node::JSUDPWrap::Initialize) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters