Myipp.Web.RPC
1.0.0
See the version list below for details.
dotnet add package Myipp.Web.RPC --version 1.0.0
NuGet\Install-Package Myipp.Web.RPC -Version 1.0.0
<PackageReference Include="Myipp.Web.RPC" Version="1.0.0" />
paket add Myipp.Web.RPC --version 1.0.0
#r "nuget: Myipp.Web.RPC, 1.0.0"
// Install Myipp.Web.RPC as a Cake Addin #addin nuget:?package=Myipp.Web.RPC&version=1.0.0 // Install Myipp.Web.RPC as a Cake Tool #tool nuget:?package=Myipp.Web.RPC&version=1.0.0
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.3)
- System.Net.Http (>= 4.3.4)
-
.NETFramework 4.5
- Newtonsoft.Json (>= 13.0.3)
- System.Net.Http (>= 4.3.4)
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
- System.Net.Http (>= 4.3.4)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- System.Net.Http (>= 4.3.4)
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
- System.Net.Http (>= 4.3.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.