-
Hello, this isn't exactly a question specific to just edge-js, but this seems like a good place to ask it! I'm currently working on a C#/JS project that uses the slippi-js JavaScript library to find instances of specific situations within replay files for Super Smash Bros. Melee games. Currently I use named pipes so that my C# parser can send a request for data from specific replay files to my JS code, then receive that data in JSON form and parse it. The slippi-js library is the best option available for getting data from the replay files, so it's essentially a requirement that I use it in my project. The named pipe system does the job, but I've been looking into using this library to write an interpreter as an alternative approach. My question is, what's the best way to include an external JS library (like slippi-js) in my project such that it can still be processed correctly by edge-js? The README says this, which I understand and makes sense to me.
However, when it comes to publishing a stand-alone version of my project, I'm not sure how I could satisfy that requirement while also including the slippi-js library. I'm also pretty unsure as to how including JS libraries in a Visual Studio C# project generally works, it's been a little hard to find good info on it. The best lead I've found/idea I've had so far is modifying the repositoryPath in the project's nuget.config such that it puts the edge-js NuGet package into a specific packages/library folder within the project folder, then also installing the JS library into that folder. However, I'm not sure if that would accomplish what I want, or even be a good idea in the first place. Any help would be appreciated, this has been a real head-scratcher! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There are no additional steps needed but it depends on your solution structure. Using an example from readme it would look like this:
{
"name": "edge-js-websockets",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"description": "",
"dependencies": {
"ws": "^8.18.0"
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AssemblyTitle>Websockets</AssemblyTitle>
<Product>Websockets</Product>
<Copyright>Copyright © 2024</Copyright>
<OutputPath>bin\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EdgeJs" Version="20.12.3" />
</ItemGroup>
<ItemGroup>
<Content Include="edge\double_edge.js" />
<Content Include="edge\edge.js" />
<Content Include="edge\x64\edge_nativeclr.node" />
<Content Include="edge\x64\libnode.dll" />
<Content Include="edge\x86\edge_nativeclr.node" />
<Content Include="edge\x86\libnode.dll" />
</ItemGroup>
</Project>
using System;
using System.Threading;
using System.Threading.Tasks;
using EdgeJs;
namespace Websockets
{
internal class Program
{
public static async void Start()
{
var createWebSocketServer = Edge.Func(@"
var WebSocketServer = require('ws').Server;
return function (port, cb) {
var wss = new WebSocketServer({ port: port });
wss.on('connection', function (ws) {
ws.on('message', function (message) {
ws.send(message.toString().toUpperCase());
});
ws.send('Hello!');
});
cb();
};
");
await createWebSocketServer(8080);
}
static void Main(string[] args)
{
Task.Run((Action)Start);
new ManualResetEvent(false).WaitOne();
}
}
} When deploying solution you would need to copy Based on the above example deployed application would have
|
Beta Was this translation helpful? Give feedback.
There are no additional steps needed but it depends on your solution structure. Using an example from readme it would look like this:
package.json
Websockets.sln