Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions netlinkwrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void NetLinkWrapper::Init(Local<Object> exports)

// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
tpl->SetClassName(String::NewFromUtf8(isolate, "NetLinkWrapper"));
tpl->SetClassName(String::NewFromUtf8(isolate, "NetLinkWrapper").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);

// Prototype
Expand All @@ -35,7 +35,7 @@ void NetLinkWrapper::Init(Local<Object> exports)
NODE_SET_PROTOTYPE_METHOD(tpl, "disconnect", Disconnect);

constructor.Reset(isolate, Nan::GetFunction(tpl).ToLocalChecked());
exports->Set(String::NewFromUtf8(isolate, "NetLinkWrapper"), Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(exports, Nan::New<String>("NetLinkWrapper").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked());
}

void NetLinkWrapper::New(const FunctionCallbackInfo<Value>& args)
Expand Down Expand Up @@ -69,13 +69,13 @@ void NetLinkWrapper::Connect(const FunctionCallbackInfo<Value>& args)

if(args.Length() != 2 && args.Length() != 1)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' requires the arguments port and optionally host")));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' requires the arguments port and optionally host").ToLocalChecked()));
return;
}

if(!args[0]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' second arg should be number for port on server")));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'connect' second arg should be number for port on server").ToLocalChecked()));
return;
}
int port = (int)args[0]->NumberValue(isolate->GetCurrentContext()).FromJust();
Expand All @@ -93,7 +93,7 @@ void NetLinkWrapper::Connect(const FunctionCallbackInfo<Value>& args)
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}
}
Expand All @@ -114,7 +114,7 @@ void NetLinkWrapper::Blocking(const FunctionCallbackInfo<Value>& args)
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}
args.GetReturnValue().Set(Boolean::New(isolate, blocking));
Expand All @@ -123,23 +123,23 @@ void NetLinkWrapper::Blocking(const FunctionCallbackInfo<Value>& args)
{
if(!args[0]->IsBoolean())
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "first optional arg when passed must be boolean to set blocking to")));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "first optional arg when passed must be boolean to set blocking to").ToLocalChecked()));
return;
}

try
{
obj->socket->blocking(args[0]->BooleanValue(isolate->GetCurrentContext()).FromJust());
obj->socket->blocking(args[0]->BooleanValue(args.GetIsolate()));
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}
}
else
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "too many args sent to blocking")));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "too many args sent to blocking").ToLocalChecked()));
return;
}
}
Expand All @@ -153,7 +153,7 @@ void NetLinkWrapper::Read(const FunctionCallbackInfo<Value>& args)

if((args.Length() != 1 && args.Length() != 2) || !args[0]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'read' first argument must be a number representing how many bytes to try to read")));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'read' first argument must be a number representing how many bytes to try to read").ToLocalChecked()));
return;
}
size_t bufferSize = (int)args[0]->NumberValue(isolate->GetCurrentContext()).FromJust();
Expand All @@ -162,11 +162,11 @@ void NetLinkWrapper::Read(const FunctionCallbackInfo<Value>& args)
if(args.Length() == 2 && args[0]->IsBoolean()) {
try
{
obj->socket->blocking(args[1]->BooleanValue(isolate->GetCurrentContext()).FromJust());
obj->socket->blocking(args[1]->BooleanValue(args.GetIsolate()));
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}
}
Expand All @@ -178,14 +178,14 @@ void NetLinkWrapper::Read(const FunctionCallbackInfo<Value>& args)
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}

if(bufferRead > -1 && bufferRead <= (int)bufferSize) // range check
{
std::string read(buffer, bufferRead);
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, read.c_str()));
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, read.c_str()).ToLocalChecked());
}
//else it did not read any data, so this will return undefined

Expand All @@ -201,7 +201,7 @@ void NetLinkWrapper::Write(const FunctionCallbackInfo<Value>& args)

if(args.Length() != 1 || !args[0]->IsString())
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'send' first argument must be a string to send")));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "'send' first argument must be a string to send").ToLocalChecked()));
return;
}
Nan::Utf8String param1(args[0]);
Expand All @@ -213,7 +213,7 @@ void NetLinkWrapper::Write(const FunctionCallbackInfo<Value>& args)
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}
}
Expand All @@ -231,7 +231,7 @@ void NetLinkWrapper::Disconnect(const FunctionCallbackInfo<Value>& args)
}
catch(NL::Exception& e)
{
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what())));
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, e.what()).ToLocalChecked()));
return;
}
}