Skip to content

Commit

Permalink
Update addon.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed May 11, 2024
1 parent 496fd84 commit ad2a338
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ using namespace v8;

#include "Multipart.h"

void uWS_log(const FunctionCallbackInfo<Value> &args) {

Isolate *isolate = args.GetIsolate();

char buf[256];
int len = Local<String>::Cast(args[0])->WriteUtf8(isolate, buf);


fwrite(stdout, buf, len);
}

/* This function is somewhat of a simplifying wrapper that does not follow the C++ library.
* It takes a POST:ed body and contentType, and returns an array of parts if
* the request is a multipart request */
Expand Down Expand Up @@ -417,6 +428,9 @@ PerContextData *Main(Local<Object> exports) {
exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "_cfg", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_cfg)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()).ToChecked();
exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "getParts", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_getParts)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()).ToChecked();

exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "log", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_log)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()).ToChecked();


/* Expose some µSockets functions directly under uWS namespace */
exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "us_listen_socket_close", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_us_listen_socket_close)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()).ToChecked();
exports->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "us_socket_local_port", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_us_socket_local_port)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()).ToChecked();
Expand Down

0 comments on commit ad2a338

Please sign in to comment.