node.js addon call javascript function failed

I want to call a javascript function(which is in the test.js) from my C++ addon by name but not pass it as an argument in the FunctionCallbackInfo<Value> object. Version of my node.js is 6.10.2.


function callme(msg)
const addon = require('./build/Debug/addon11');


namespace demo
    using v8::FunctionCallbackInfo;
    using v8::Isolate;
    using v8::Local;
    using v8::Object;
    using v8::String;
    using v8::Value;
    using v8::Exception;
    using v8::Function;
    using v8::Context;
    using v8::HandleScope;
    using v8::MaybeLocal;

    void Method(const FunctionCallbackInfo<Value>& args)
        Isolate* isolate = Isolate::GetCurrent();
        HandleScope scope(isolate);
        Local<Context> context = isolate->GetCurrentContext();
        Local<Object> global = context->Global();
        if (global.IsEmpty() || global->IsNull())
        MaybeLocal<Value> mbValue = global->Get(String::NewFromUtf8(isolate, "callme"));
        if (mbValue.IsEmpty())
            isolate->ThrowException(Exception::Error(String::NewFromUtf8(isolate, "can't find the function callme!")));
        Local<Value> vTmp = mbValue.ToLocalChecked();
        if (!vTmp->IsFunction())
            return;//it will retun here
        Local<Function> callFunc = Local<Function>::Cast(vTmp);
        Local<Value> argv[] = { String::NewFromUtf8(isolate, "call from c++") };
        callFunc->Call(Null(isolate), 1, argv);

    void init(Local<Object> exports)
        NODE_SET_METHOD(exports, "StartRun", Method);

    NODE_MODULE(addon11, init)

when I debug the code it returns here:

        Local<Value> vTmp = mbValue.ToLocalChecked();
        if (!vTmp->IsFunction())
            return;//it will retun here

Source: stackoverflow-javascript

PHP COM and C# "Out" and boolean Parameters

I’m connecting through PHP “COM” to an API that is compatible with C#,C++ etc.
I have successfully made connection with the application and trying to use “out” parameters through COM and getting a “type mismatch” error. Is the “out” parameter and is supposed to house the response and then the false. I’m not sure if it fails on that or if it fails on the false.. but either way I can’t get this to work.

the C# example looks like this:

Dim aViews As Array = Nothing
vault.GetVaultViews(aViews, False)

the php code looks like this:

$this->aviews = array();      
try {

         $this->epdm->GetVaultViews($this->aviews, False );

   } catch (Exception $e) {

        echo 'Caught exception: ',  $e->getMessage(), "n";


I get the following returned errors:
Caught exception: Parameter 1: Type mismatch.

Hope someone can help!

Source: stackoverflow-php

Translating PHP http request into C# .NET

I have written this code in PHP to make a HTTP request to my server to retrieve my data:


$client_secret= '';
$data= array(

'email' => '**********',

'password' => '******',

'client_id' => '*******'



$signature_string = md5($json_data . $client_secret); 

$post_data = 'signature='.$signature_string.'&data='.urlencode($json_data);

$curl = curl_init($api_url); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_POST, 1); 

curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);

$result = curl_exec($curl); 




And this works good. Data is returned in JSON format. Now I’m trying to do exactly the same thing but in .NET

I have managed to recreate in .NET C# exactly the same postData parameter as in PHP, but I’m not sure how to pass it in C# with the request itself… So I’ve decided to use .NET’s restsharp library to make the request like this:

  public void GetResponse()
            string client_secret = "*****";

            var serializer = new JavaScriptSerializer();
            string json_data = serializer.Serialize(new { email = "*****", password = "*****", client_id = "*****" });

            var signature_string = CalculateMD5Hash(json_data + client_secret).ToLower();

            var postData = "signature=" + signature_string + "&data=" + Server.UrlEncode(json_data);
            var client = new RestClient("");
            var request = new RestRequest(Method.POST);
            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            request.AddHeader("cache-control", "no-cache");
            request.AddParameter("application/x-www-form-urlencoded", "signature="+signature_string, ParameterType.RequestBody);
            request.AddParameter("application/x-www-form-urlencoded", "data=" +json_data, ParameterType.RequestBody);

            IRestResponse response = client.Execute(request);


Please note in C# and in PHP variables:



var postdata

are exactly identical. Now I just don’t know how to pass them alongside the request because the server always responds me that request data was empty..

What am I doing wrong here?

Source: stackoverflow-php

overload null in api restful methods ajax

I am creating a UI for a content production area on a company intranet. I created the middleware API in a previous project. This is my first tie using RESTful methods (and I’m fairly new to Javascript and jquery in the first place)

When I call my debugging local api from the jquery.ajax the JSON objet is not beig passed properly on my GET method.

In the C# API
public string GetThing(object json)
GetData getData;
if (json == null)
return null;
else if (json is string && (json as string).StartsWith(“{“))
getData = JsonConvert.DeserializeObject(json as string);
return null;
ItemReturn retVAl = new ItemReturn();

[logic to use JSON]

return retVal;

in the web page

loadThings: function (thingNumber, showBool) {
                showBool = (showBool === true);
                    type: "GET",
                    dataType: "json",
                    data: '{ "GetData" : {"ThingNumber":"' + thingNumber + '","Show": ' + showBool + '}}',
                    url: "http://localhost:11422/api/THING/THING/GetThing",
                    contentType: "application/json; charset=utf-8",

                    success: function (result) {

[logic to display things]


I can hit my breakPoint in GetThing fine, hat all work, but I can’t seem to figure out why the object (json) in my overload is coming in null. I know it’s something in the javascript, my unit tests work fine and my JavaScript is getting me to my breakpoint in the method, I just need to overloaded JSON object to actually b passed in

Source: stackoverflow-javascript

Eikon Fingerprint Scanner PHP/SQL integration

Seeing if anyone has any good examples on how to integrate a fingerprint scanner into a php/sql database. We are working with two Eikon 710/510 fingerprint readers. We wish to be able to have a user scan their print, store that data in the db, and have them open a door connected to another reader.
We have not found much documentation on these. We have the SDK, unfortunetly it is all in C++ which we do not have much experience in. We were wondering if anyone would be able to point us to some examples?

Source: stackoverflow-php

JavaScript "Packed" Function in CSharp

I have an obfuscated (p,a,c,k,e,d) function from JavaScript.

string value = @"eval(function(p,a,c,k,e,d)
            {while(c--)if(k[c])p=p.replace(new RegExp('b'+c.toString(a)+'b','g'),k[c]);
            return p}
('3("3b").3a({39:"5://1b.1a.19.8:18/38/v.37",36:"5://1b.1a.19.8:18/i/35/34/33.32",31:"",30:"2z",2y:"2x",2w:2v,2u:"7",2t:"2s",2r:[],2q:{2p:'#2o',2n:22,2m:"2l",2k:0}});b f;b k=0;b 6=0;3().2j(2(x){a(6>0)k+=x.17-6;6=x.17;a(0!=0&&k>=0){6=-1;3().2i();3().2h(2g);$('#2f').j();$('h.g').j()}});3().2e(2(x){6=-1});3().2d(2(x){16(x)});3().2c(2(){$('h.g').j()});2 16(x){$('h.g').2b();a(f)2a;f=1;$.29('5://12.9/15-28/27.15?26=25&24=23&21=20-1z-1y-1x-1w',2(14){$('#1v').1u(14)})};3().1t('1s',2(){b 13=3().1r();13.1q('1p',2(){11.10('z-y')[0].w[1].1o="5://12.9";11.10('z-y')[0].w[1].1n="<u>1m - 1l 1k 1j & 1i</u>"});a($.c('4')=="d"){t.s("5://r.q.p/o/7.n","m 9 1h",e,"l")}1g{t.s("5://r.q.p/o/d.n","m 9 1f",e,"l")}});2 e(){$.c('4')=='7'?4='d':4='7';$.c('4',4);1e.1d.1c()};',36,120,'||function|jwplayer|primaryCookie|http|p02887336|html5||to|if|var|cookie|flash|switchMode|vvplay|video_ad|div||show|tt2887336|button2|Switch|png|images|tv|flashx|static|addButton|this|center||childNodes||featured|jw|getElementsByClassName|document|streamin|container|data|cgi|doPlay|position|8777|213|211|95|reload|location|window|Flash|else|HTML5|Storage|Sharing|Video|Free|Streamin|innerHTML|href|contextmenu|addEventListener|getContainer|ready|on|html|fviews|fb98c55a544241de2464a88086a6b0c9|1486917733|186|182|2887336|hash||2ca0tpqawtre|file_code|view|op|index_dl|bin|get|return|hide|onComplete|onPlay|onSeek|play_limit_box|false|setFullscreen|stop|onTime|backgroundOpacity|Arial|fontFamily|fontSize|FFFFFF|color|captions|tracks|start|startparam|primary|326|height|580|width|2638|duration|skin|jpg|lhl2j9yhfp1s|00085|01|image|mp4|rwi7bsgc5huzcg3h5fpsfen3362uwfp4cyzyo2mavczsvbbx4tnesmwhdteq|file|setup|vplayer'.split('|')))"

I am trying to use jint to interpret and get the value of the above function but when I execute the statement in jint engine it throws an exception for jwplayer is not defined.

I know why the exception is thrown but I only want to get the value of p above. But jint runs the whole function and then ends up with an empty function which doesn’t exist and when it tries to run it, an exception is thrown.

I only want it to return the value in a string and it should not run it any further. I have already tried to search it for an answer but so far found nothing.
I am using the code as following:

 Jint.Engine jEngine = new Jint.Engine();
 var linkString = jEngine.Execute(value).GetCompletionValue().ToString();
 var arrayFile = linkString.Split(' ', 'n');

Is something I am missing here? If someone can shed some light on it. That will be much appreciated. Thanks

Source: stackoverflow-javascript