|
@@ -12,6 +12,15 @@ using WingServerCommon.Config.Parameters;
|
|
|
using WingInterfaceLibrary.OpLog;
|
|
|
using WingCloudServer.InteractionCenter;
|
|
|
using System.Runtime.Loader;
|
|
|
+using JsonRpcLite.Utilities;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using WingInterfaceLibrary.Interface.DBInterface;
|
|
|
+using WingInterfaceLibrary.Interface;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using WingInterfaceLibrary.Request.Authentication;
|
|
|
+using JsonRpcLite.Services;
|
|
|
+using WingInterfaceLibrary.Enum;
|
|
|
+using WingCloudServer.Plugin;
|
|
|
|
|
|
namespace WingCloudServer
|
|
|
{
|
|
@@ -20,22 +29,35 @@ namespace WingCloudServer
|
|
|
private JsonRpcServer _rpcHttpServer;
|
|
|
private JsonRpcServer _rpcInProcessServer;
|
|
|
private JsonRpcInProcessEngine _inProcessEngine;
|
|
|
+
|
|
|
+ private JsonRpcHttpServerEngine jsonRpcHttpServerEngine;
|
|
|
public WingServer(string host)
|
|
|
{
|
|
|
_rpcInProcessServer = new JsonRpcServer();
|
|
|
_inProcessEngine = new JsonRpcInProcessEngine();
|
|
|
-
|
|
|
_rpcInProcessServer.UseEngine(_inProcessEngine);
|
|
|
_rpcHttpServer = new JsonRpcServer();
|
|
|
- var jsonRpcHttpServerEngine = new JsonRpcHttpServerEngine(host);
|
|
|
+ jsonRpcHttpServerEngine = new JsonRpcHttpServerEngine(host);
|
|
|
_rpcHttpServer.UseEngine(jsonRpcHttpServerEngine);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private TokenVerifyPlugin tokenVerifyPlugin;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Start server to load all service
|
|
|
/// </summary>
|
|
|
internal void Start()
|
|
|
{
|
|
|
InitializeServices();
|
|
|
+ //按注册顺序执行
|
|
|
+ jsonRpcHttpServerEngine.RegisterPlugin(tokenVerifyPlugin);
|
|
|
_rpcInProcessServer.Start();
|
|
|
_rpcHttpServer.Start();
|
|
|
}
|
|
@@ -54,7 +76,7 @@ namespace WingCloudServer
|
|
|
{
|
|
|
//initiaize rpc client pool
|
|
|
var remoteRpcHttpServices = LoadRemoteServiceConfig();//new RemoteServiceInfo[0];
|
|
|
- var rpcClientPool = new JsonRpcClientPool(_inProcessEngine);
|
|
|
+ var rpcClientPool = new JsonRpcClientPool(_inProcessEngine);
|
|
|
rpcClientPool.Initialize(remoteRpcHttpServices.ToArray());
|
|
|
|
|
|
var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
|
|
@@ -93,14 +115,14 @@ namespace WingCloudServer
|
|
|
}
|
|
|
|
|
|
//Rpc http service load and register to rpc http server
|
|
|
- if(ConfigurationManager.IsDistributed)
|
|
|
+ if (ConfigurationManager.IsDistributed)
|
|
|
{
|
|
|
- if(ConfigurationManager.IsMaster)
|
|
|
+ if (ConfigurationManager.IsMaster)
|
|
|
{
|
|
|
- var masterInteractionCenterService = new MasterInteractionCenterService();
|
|
|
+ var masterInteractionCenterService = new MasterInteractionCenterService();
|
|
|
_rpcHttpServer.RegisterService(typeof(IMasterInteractionCenterService), masterInteractionCenterService);
|
|
|
masterInteractionCenterService.Load(rpcClientPool);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -147,7 +169,7 @@ namespace WingCloudServer
|
|
|
//load service if distrubuted system
|
|
|
if (ConfigurationManager.IsDistributed)
|
|
|
{
|
|
|
- if(ConfigurationManager.IsMaster)
|
|
|
+ if (ConfigurationManager.IsMaster)
|
|
|
{
|
|
|
//_rpcHttpServer.RegisterService(IMaster); TODO
|
|
|
}
|
|
@@ -160,6 +182,12 @@ namespace WingCloudServer
|
|
|
var vinnoServerService = new VinnoServerService();
|
|
|
_rpcHttpServer.RegisterService(typeof(WingInterfaceLibrary.Interface.IVinnoServerService), vinnoServerService);
|
|
|
vinnoServerService.Load(rpcClientPool);
|
|
|
+
|
|
|
+ //plugin
|
|
|
+ tokenVerifyPlugin = new TokenVerifyPlugin();
|
|
|
+ _rpcHttpServer.RegisterService(typeof(ITokenVerifyPlugin), tokenVerifyPlugin);
|
|
|
+ tokenVerifyPlugin.Load(rpcClientPool);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private Type LoadService(string folder, object serviceName)
|
|
@@ -169,7 +197,7 @@ namespace WingCloudServer
|
|
|
{
|
|
|
throw new NotSupportedException($"File {file} not exist");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var assembly = AssemblyLoader.LoadAssemblyDependencies(file);
|
|
|
var types = assembly.GetTypes();
|
|
|
var wingServiceType = types.FirstOrDefault(x => typeof(JsonRpcService).IsAssignableFrom(x) && x.IsClass && !x.IsAbstract);
|
|
@@ -198,7 +226,7 @@ namespace WingCloudServer
|
|
|
{
|
|
|
throw new NotSupportedException($"File {file} not exist");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var assembly = AssemblyLoader.LoadAssemblyDependencies(file);
|
|
|
var types = assembly.GetTypes();
|
|
|
var namespaceStr = $"{defaultInterfaceName}.{defaultInterfaceFolder}";
|
|
@@ -235,17 +263,17 @@ namespace WingCloudServer
|
|
|
private List<RemoteServiceInfo> LoadRemoteServiceConfig()
|
|
|
{
|
|
|
List<RemoteServiceInfo> resList = new List<RemoteServiceInfo>();
|
|
|
- if(ConfigurationManager.IsDistributed)
|
|
|
+ if (ConfigurationManager.IsDistributed)
|
|
|
{
|
|
|
- if(ConfigurationManager.IsMaster)
|
|
|
+ if (ConfigurationManager.IsMaster)
|
|
|
{
|
|
|
- //TODO determin if we need to assess slave server on master server
|
|
|
+ //TODO determin if we need to assess slave server on master server
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var serviceInfo = new RemoteServiceInfo()
|
|
|
+ var serviceInfo = new RemoteServiceInfo()
|
|
|
{
|
|
|
- ServiceName="IMasterInteractionCenterService",
|
|
|
+ ServiceName = "IMasterInteractionCenterService",
|
|
|
Url = ConfigurationManager.MasterUrl
|
|
|
};
|
|
|
resList.Add(serviceInfo);
|
|
@@ -283,7 +311,7 @@ namespace WingCloudServer
|
|
|
return resList;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化AIDiagnosis
|