tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.41k stars 639 forks source link

how can i hold node object in .net CLR? #609

Closed doukai closed 4 months ago

doukai commented 6 years ago

how can i hold node object in .net CLR,impossible?

tjanczuk commented 6 years ago

Hello World!

doukai commented 6 years ago

@tjanczuk i need your help,i want to save a object of node.js in my c# code,do you have Any good ideas?thank you so much!

doukai commented 6 years ago
            var getCam = Edge.Func(@"

                var Cam = require('onvif').Cam;

                return function (data, callback) {

                    new Cam({
                        hostname: '{0}',
                        username: '{1}',
                        password: '{2}',
                        port: {3}
                    }, function (err) {
                        if (err) {
                            callback(err);
                        }

                        callback(null,this);
                    });
                };
            ".Replace("{0}", CAMERA_HOST).Replace("{1}", USERNAME).Replace("{2}", PASSWORD).Replace("{3}", PORT));

            var cam = await getCam(null);

            var func = Edge.Func(@"

                return function (cam, callback) {

                    cam.getStreamUri({ protocol: 'RTSP' }, function (err, stream) {

                            callback(err, stream.uri);
                    });
                };
            ".Replace("{0}", CAMERA_HOST).Replace("{1}", USERNAME).Replace("{2}", PASSWORD).Replace("{3}", PORT));

            var uri = await func(cam);

I want to hold the cam object in my c# code, somebody have any good ideas? thanks~