-
Notifications
You must be signed in to change notification settings - Fork 632
Open
Description
Hello, I am a newer of edge-js, I create a C# dll project, source code as bellow:
namespace NodeDemo
{
public class Printer
{
private string name;
public async Task<object> Init(string param)
{
this.name = param;
return this.name;
}
public async Task<object> SayHello(string param)
{
return "Hello, " + name;
}
public async Task<object> SayGoodbye(string param)
{
return "Goodbye, " + name;
}
}
}
And I got the dll file, put it in my node project, then create an api.js like this:
var edge = require('edge')
var path = require('path')
var init = edge.func({
assemblyFile: path.join(__dirname, '../dll/NodeDemo.dll'),
typeName: 'NodeDemo.Printer',
methodName: 'Init'
})
var sayHello = edge.func({
assemblyFile: path.join(__dirname, '../dll/NodeDemo.dll'),
typeName: 'NodeDemo.Printer',
methodName: 'SayHello'
})
var sayGoodbye = edge.func({
assemblyFile: path.join(__dirname, '../dll/NodeDemo.dll'),
typeName: 'NodeDemo.Printer',
methodName: 'SayGoodbye'
})
module.exports = {
init,
sayHello,
sayGoodbye
}
Finally, I create an index.js like this:
var printer = require('./api/printer')
printer.init('yaphone', function(err, result) {
if (err) throw err
console.log(result)
})
printer.sayHello('', function(err, result) {
if (err) throw err
console.log(result)
})
printer.sayGoodbye('', function(err, result) {
if (err) throw err
console.log(result)
})
I try to run node index.js, and I got output in the console like this:
yaphone
Hello,
Goodbye,
But, my expect output is this:
yaphone
Hello, yaphone
Goodbye, yaphone
I suspect this is related to the life cycle of the dll, because I load the dll three times in node. So, how can I load once, and use the three methods in the dll?
Thx for any replies!
Metadata
Metadata
Assignees
Labels
No labels