Rpc.Synpase.Icarus 1.4.3

dotnet add package Rpc.Synpase.Icarus --version 1.4.3
NuGet\Install-Package Rpc.Synpase.Icarus -Version 1.4.3
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="Rpc.Synpase.Icarus" Version="1.4.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rpc.Synpase.Icarus --version 1.4.3
#r "nuget: Rpc.Synpase.Icarus, 1.4.3"
#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 Rpc.Synpase.Icarus as a Cake Addin
#addin nuget:?package=Rpc.Synpase.Icarus&version=1.4.3

// Install Rpc.Synpase.Icarus as a Cake Tool
#tool nuget:?package=Rpc.Synpase.Icarus&version=1.4.3

西纳普斯 - synapse (C# Version)

此为系统核心交互组件,包含了事件和RPC系统

包地址

https://www.nuget.org/packages/Rpc.Synapse.Icarus

可以使用Nuget安装

Install-Package Rpc.Synapse.Icarus

使用前奏:
  1. 需要一个RabbitMQ服务器
使用方式:
    var app = new Synapse();
    app.MqHost = "xxxx";
    app.MqPort = "5672";
    app.MqUser = "guest";
    app.MqPass = "guest";
    app.SysName = "simcu";
    app.AppName = "dotNet";
    app.Debug = true;
    app.EventCallback = new TestEventServer();
    app.RpcCallback = new TestServer();
    app.Serve();
CallBack类说明:

callback类中需要有一个 public Dictionary<string, string> RegAlias() 方法,返回一个请求对应的字典,对于RPC来说为调用名和执行方法名的关联,对于EVENT来说,为监听事件和执行方法名的对应; 所有的Callback均需要继承BaseCallback类 注意: 不支持#和*通配符

public class BaseCallback
{
    public virtual Dictionary<string, string> RegAlias()
    {
        return new Dictionary<string, string>() { };
    }
}

RPC回调方法类型:

// data 为json反序列化后的对象
// ea 是mq接收到的原始数据
public JObject tb(JObject data, BasicDeliverEventArgs ea)
{
    var ret = new Dictionary<string, object>();
    ret.Add("suceess", "I 收到了");
    ret.Add("m", data.msg);
    ret.Add("number", 5233);
    return ret;
}

事件回调方法类型:

// data 为json反序列化后的对象
// ea 是mq接收到的原始数据
// 返回true系统将会应答消息,返回false系统将重新将消息放入队列
public bool tb(JObject data, BasicDeliverEventArgs ea)
{
    return true;
}
日志说明:

LoggerServer实现了全局日志功能,回调需要继承 BaseLogger

public class BaseLogger
{
    //记录所有日志
    public virtual void All(JObject data, BasicDeliverEventArgs ea)
    {
    }

    //记录事件日志
    public virtual void Event(JObject data, BasicDeliverEventArgs ea)
    {
    }

    //记录请求日志
    public virtual void Request(JObject data, BasicDeliverEventArgs ea)
    {
    }

    //记录响应日志
    public virtual void Response(JObject data, BasicDeliverEventArgs ea)
    {
    }
}
客户端方法说明:
  1. 发送事件

Synapse.SendEvent(string eventName, JObject param)

  1. RPC请求

Synapse.SendRpc(string server, string method, JObject param)

  1. 控制台日志

Synapse.Log(string desc, string type = "Info")

日志级别: LogWarn,LogError,LogInfo,LogDebug

参数说明:
public string MqHost;               //MQ主机
public string MqPort = "5672";      //MQ端口
public string MqUser;               //MQ用户
public string MqPass;               //MQ密码
public string MqVHost = "/";        //MQ虚拟机名称,默认为/
public string SysName;              //系统名称(都处于同一个系统下才能通讯)
public string AppName;              //应用名(当前应用的名字,不能于其他应用重复)
public string AppId;                //应用ID(支持分布式,不输入会每次启动自动随机生成)
public int RpcTimeout = 3;          //RPC请求超时时间(只针对客户端有效)
public int EventProcessNum = 20;    //事件服务并发量
public int RpcProcessNum = 20;      //RPC服务并发量
public bool DisableEventClient;     //禁用事件客户端
public bool DisableRpcClient;       //禁用RPC客户端
public bool Debug;                  //调试
public BaseCallback RpcCallback;    //RPC处理类(不指定默认禁用)
public BaseCallback EventCallback;  //Event处理类(不指定默认禁用)
public BaseLogger LoggerCallback;   //日志处理类(不指定默认禁用)
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 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.4.3 1,113 3/14/2018