2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 03:32:57 +00:00
2024-10-12 14:06:08 +03:00

1.2 KiB

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

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

    [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

let x = await wh.get("iip://localhost:8080/sys/service", {secure: false});
await x.Hello();