Browse Source

set useSSL

Melon 2 years ago
parent
commit
c8c978b6dd
1 changed files with 57 additions and 58 deletions
  1. 57 58
      lib/rpc.dart

+ 57 - 58
lib/rpc.dart

@@ -34,8 +34,11 @@ class JsonRpcProxy {
   /// 服务主机地址
   late String _currentHost;
 
+  /// 服务主机协议
+  late String _currentProtocol;
+
   /// 当前服务主机地址
-  String get currentHostAddress => "http://$_currentHost";
+  String get currentHostAddress => "$_currentProtocol://$_currentHost";
 
   HashMap<Type, dynamic> _serviceCache = HashMap();
 
@@ -50,93 +53,90 @@ class JsonRpcProxy {
     return _platformService!;
   }
 
-	LiveConsultationService get liveConsultation =>
-	findService(() => new LiveConsultationService(currentHostAddress));
-
-	AIDiagnosisService get aIDiagnosis =>
-	findService(() => new AIDiagnosisService(currentHostAddress));
+  LiveConsultationService get liveConsultation =>
+      findService(() => new LiveConsultationService(currentHostAddress));
 
-	ASRService get aSR =>
-	findService(() => new ASRService(currentHostAddress));
+  AIDiagnosisService get aIDiagnosis =>
+      findService(() => new AIDiagnosisService(currentHostAddress));
 
-	AuthenticationService get authentication =>
-	findService(() => new AuthenticationService(currentHostAddress));
+  ASRService get aSR => findService(() => new ASRService(currentHostAddress));
 
-	ConnectService get connect =>
-	findService(() => new ConnectService(currentHostAddress));
+  AuthenticationService get authentication =>
+      findService(() => new AuthenticationService(currentHostAddress));
 
-	DeployPlatformService get deployPlatform =>
-	findService(() => new DeployPlatformService(currentHostAddress));
+  ConnectService get connect =>
+      findService(() => new ConnectService(currentHostAddress));
 
-	DeviceService get device =>
-	findService(() => new DeviceService(currentHostAddress));
+  DeployPlatformService get deployPlatform =>
+      findService(() => new DeployPlatformService(currentHostAddress));
 
-	EducationService get education =>
-	findService(() => new EducationService(currentHostAddress));
+  DeviceService get device =>
+      findService(() => new DeviceService(currentHostAddress));
 
-	EmailService get email =>
-	findService(() => new EmailService(currentHostAddress));
+  EducationService get education =>
+      findService(() => new EducationService(currentHostAddress));
 
-	IdentityApplyService get identityApply =>
-	findService(() => new IdentityApplyService(currentHostAddress));
+  EmailService get email =>
+      findService(() => new EmailService(currentHostAddress));
 
-	LabService get lab =>
-	findService(() => new LabService(currentHostAddress));
+  IdentityApplyService get identityApply =>
+      findService(() => new IdentityApplyService(currentHostAddress));
 
-	LoginService get login =>
-	findService(() => new LoginService(currentHostAddress));
+  LabService get lab => findService(() => new LabService(currentHostAddress));
 
-	OrganizationService get organization =>
-	findService(() => new OrganizationService(currentHostAddress));
+  LoginService get login =>
+      findService(() => new LoginService(currentHostAddress));
 
-	PatientService get patient =>
-	findService(() => new PatientService(currentHostAddress));
+  OrganizationService get organization =>
+      findService(() => new OrganizationService(currentHostAddress));
 
-	PaymentService get payment =>
-	findService(() => new PaymentService(currentHostAddress));
+  PatientService get patient =>
+      findService(() => new PatientService(currentHostAddress));
 
-	PositionService get position =>
-	findService(() => new PositionService(currentHostAddress));
+  PaymentService get payment =>
+      findService(() => new PaymentService(currentHostAddress));
 
-	RankService get rank =>
-	findService(() => new RankService(currentHostAddress));
+  PositionService get position =>
+      findService(() => new PositionService(currentHostAddress));
 
-	RecordInfoService get recordInfo =>
-	findService(() => new RecordInfoService(currentHostAddress));
+  RankService get rank =>
+      findService(() => new RankService(currentHostAddress));
 
-	RegionService get region =>
-	findService(() => new RegionService(currentHostAddress));
+  RecordInfoService get recordInfo =>
+      findService(() => new RecordInfoService(currentHostAddress));
 
-	RemedicalService get remedical =>
-	findService(() => new RemedicalService(currentHostAddress));
+  RegionService get region =>
+      findService(() => new RegionService(currentHostAddress));
 
-	ReportService get report =>
-	findService(() => new ReportService(currentHostAddress));
+  RemedicalService get remedical =>
+      findService(() => new RemedicalService(currentHostAddress));
 
-	RoleService get role =>
-	findService(() => new RoleService(currentHostAddress));
+  ReportService get report =>
+      findService(() => new ReportService(currentHostAddress));
 
-	SMSService get sMS =>
-	findService(() => new SMSService(currentHostAddress));
+  RoleService get role =>
+      findService(() => new RoleService(currentHostAddress));
 
-	StorageService get storage =>
-	findService(() => new StorageService(currentHostAddress));
+  SMSService get sMS => findService(() => new SMSService(currentHostAddress));
 
-	UpgradeService get upgrade =>
-	findService(() => new UpgradeService(currentHostAddress));
+  StorageService get storage =>
+      findService(() => new StorageService(currentHostAddress));
 
-	UserService get user =>
-	findService(() => new UserService(currentHostAddress));
+  UpgradeService get upgrade =>
+      findService(() => new UpgradeService(currentHostAddress));
 
-	VinnoServerService get vinnoServer =>
-	findService(() => new VinnoServerService(currentHostAddress));
+  UserService get user =>
+      findService(() => new UserService(currentHostAddress));
 
+  VinnoServerService get vinnoServer =>
+      findService(() => new VinnoServerService(currentHostAddress));
 
   /* 服务代理设置 End */
 
   /// 设置服务主机地址
-  void setServerHost(String address) {
+  void setServerHost(String address, [bool useSSL = false]) {
     logger.i('JsonRpcProxy setServerHost :' + address);
+    _currentProtocol = useSSL ? "https" : "http";
     _currentHost = address;
   }
 
@@ -156,4 +156,3 @@ class JsonRpcProxy {
     return _serviceCache[serviceType] as T;
   }
 }
-