/// <summary> /// 启动RPC服务器 /// </summary> /// <returns></returns> public static bool StartRpcServer(string remoteIp, int remotePort, string localIp, int localPort) { _remoteIp = remoteIp; _remotePort = remotePort; _localIp = localIp; _localPort = localPort; System.Reflection.Assembly.Load("Sys.Safety.WebApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); int rpcModel = Basic.Framework.Configuration.ConfigurationManager.FileConfiguration.GetInt("RpcModel", 1); if (rpcModel == 1) { _rpcModel = RpcModel.WebApiModel; } else if (rpcModel == 2) { _rpcModel = RpcModel.gRPCModel; } _client = RpcFactory.CreateRpcClient(_rpcModel, _remoteIp, _remotePort); _server = RpcFactory.CreateRpcServer(_rpcModel); _server.RegistCallback(OnRpcMessageArrived); _server.Start(_localIp, _localPort); return(true); }