microsoft / Chakra-Samples

Repository for Chakra JavaScript engine related samples.
MIT License
216 stars 84 forks source link

Bindings for C# like OpenGL C++ and some questions #37

Closed alexgwolff closed 7 years ago

alexgwolff commented 8 years ago

Hi guys,

I want use the Chakra as an engine to process some scripts, something like using the node to process JS at runtime. I saw examples of OpenGL and is exactly what I need, but I need in C # would have some examples how this would be done in C #?

I have some doubts could they respond?

Sockets.js (just javascript implementation) Sockets.dll ( C# code, for bindings socket at chakra engine)

Sorry for poor English. Thanks;

liminzhu commented 8 years ago

I wanted to use the chakra on a Web Service which would be the last to process JS, It would be interesting to keep pool of engine chakra?

Having a pool of runtimes and assigning them to incoming tenants of your service is a good idea for performance. Azure DocDB is doing the same thing (see the paragraph about rental-threading).

You would have to reset it each call ? Or is indifferent created every time you have a new script? I would have to do the 'binding' at runtime? like using the default import module ES6, I that if the import is something pure in JS works right? But what if you have to do "bindings" equal OpenGL I did not want to carry all at once. EX: import Socket from './sockets.js' in folder ./ I would

For each new context, you'd have to do the binding (a.k.a. inject all the extra stuff you want into JavaScript). If for each new context you have some scripts you'd like to run, you can use the serialization feature, which helps avoid the cost of repeatedly parsing the script. The alternative is to re-use the same context, but a previous user could have already polluted the context so there's your risk.

alexgwolff commented 8 years ago

@liminzhu Thanks for reply. Your answers helped me a lot . If you do not mind , I just had one last .

In the examples a "hosting API " . Are there any plans to offer an api with official nuget packages by microsoft ? Or left the community? I ask this because in my tests removed the " hosting " within the project , and I am making it with an external package. I'm doing with the dotnet and everything worked perfect.

liminzhu commented 8 years ago

@alexgwolff glad it helps you 😄 .

In terms of nuget packages, we have a feed incl. ChakraCore binary along with ch host. However, there's no current plan for a plug-in-n-go package for C# users with all the hosting stuff. We may look into this in the future, but if someone from the community wants to create one, we'd certainly appreciate it.

liminzhu commented 7 years ago

Close due to inactivity.