Myipp.Web.RPC 1.0.1

dotnet add package Myipp.Web.RPC --version 1.0.1                
NuGet\Install-Package Myipp.Web.RPC -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Myipp.Web.RPC" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Myipp.Web.RPC --version 1.0.1                
#r "nuget: Myipp.Web.RPC, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Myipp.Web.RPC as a Cake Addin
#addin nuget:?package=Myipp.Web.RPC&version=1.0.1

// Install Myipp.Web.RPC as a Cake Tool
#tool nuget:?package=Myipp.Web.RPC&version=1.0.1                

Myipp.Web.RPC

RPC library.

Install

Install-Package Myipp.Web.RPC

Useage of RPCHost

RPCHost can setup a rpc service, use websocket to connect rpc server, and receive remote call event and do it. First create a class for RPC method, you can use RPCMethod attribute to set rpc method name.

class Handler
{
    [RPCMethod]
    public Task test()
    {
        Console.WriteLine("test");
        return Task.FromResult(0);
    }

    [RPCMethod]
    public Task<User> test1()
    {
        Console.WriteLine("test1");
        return Task.FromResult(new User
        {
            name = "james.yang",
            age = new Random().Next(),
        });
    }

    [RPCMethod]
    public Task<string> test2()
    {
        Console.WriteLine("test2");
        return Task.FromResult("james");
    }

    [RPCMethod]
    public Task<User> test3(string name)
    {
        return Task.FromResult(new User
        {
            name = name,
            age = new Random().Next(),
        });
    }
}

var rpcgateurl = "ws://localhost:10000";
var rpc = new RPCHost("test", "testdevice");
rpc.AddHandler(typeof(Handler), new Handler());
rpc.Run(rpcgateurl);

rpc gate, you can use Myipp.Web.Api.Core library.

Useage of RPCClient

RPCClient is a rpc client, you can use it do remote call, it based on http or https.

Create instance

var apiurl = "http://localhost:10000";
var cli = new RPCClient(apiurl, "test", "testdevice");

Call remote method

public class User
{
    public string name { get; set; }
    public int age { get; set; }
}
var data = new {
	name = "tony",
	age = 10,
}
string callret = await cli.RawCall("test2", null);
User user = await cli.Call<User>("test2", "tony");

Create interface

Create a interface use interface template like follow, the method have the same name,paramters and return value, all interface must return Task or Task<T> If method name is not equeal rpc method name, you can use RPCMethod("methodname") attribute before method.

public interface IRPCTest : IRPCInterface
{
    Task test();

    Task<User> test1();

    Task<string> test2();

    Task<User> test3(string name);
}
var api = ter.CreateInterface<IRPCTest>();
await api.test();
var ret1 = await api.test1();
var ret2 = await api.test2();
var ret3 = await api.test3("james3");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 93 12/15/2024
1.0.0 75 12/15/2024