2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 03:32:57 +00:00
This commit is contained in:
Ahmed Zamil 2024-10-12 14:06:08 +03:00
parent b57352b013
commit 6cae4b3086
2 changed files with 78 additions and 24 deletions

View File

@ -9,10 +9,12 @@
<Authors>Ahmed Kh. Zamil</Authors>
<Company>Esiur Foundation</Company>
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
<RepositoryUrl>https://github.com/esiur/esiur-dotnet/</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@ -27,6 +29,7 @@
<ItemGroup>
<ProjectReference Include="..\Esiur\Esiur.csproj" />
</ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,51 @@
# Esiur ASP.Net Core Middleware
This project brings Esiur distributed resource framework to ASP.Net using WebSockets in the ASP.Net pipeline.
# Installation
- Nuget
```Install-Package Esiur.AspNetCore```
- Command-line
``` dotnet add package Esiur.AspNetCore ```
# Example
```C#
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://localhost:8080");
var app = builder.Build();
app.UseWebSockets();
await Warehouse.Put("sys", new MemoryStore());
await Warehouse.Put("sys/service", new MyResource());
var server = await Warehouse.Put("sys/server", new DistributedServer());
await Warehouse.Open();
app.UseEsiur(new EsiurOptions() { Server = server });
await app.RunAsync();
```
## MyResource.cs
```c#
[Resource]
public partial class MyResource
{
[Export] int number;
[Export] public string Hello() => "Hi";
}
```
## Calling from JavaScript
Esiur provides a command line interpreter for debugging using Node.JS which can be installed using
```npm install -g esiur```
To access the shell
```esiur shell```
Now you can simply test the running service typing
```javascript
let x = await wh.get("iip://localhost:8080/sys/service", {secure: false});
await x.Hello();
```