Browse Source

Implemented immediate switchover to RestClient after Socket Transport connected

Frank van den Bos 2 years ago
parent
commit
2b16b2314c
1 changed files with 11 additions and 2 deletions
  1. 11 2
      prs.mobile.new/PRS.Mobile/App.xaml.cs

+ 11 - 2
prs.mobile.new/PRS.Mobile/App.xaml.cs

@@ -47,9 +47,18 @@ namespace PRS.Mobile
 
             Transport = transport;
             ClientFactory.SetClientType(typeof(RpcClient<>), InABox.Core.Platform.TimeBench, MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, Transport);
+            
+            // Workaround for bug in RPCSocketServer where lrge uploads (ie photos)
+            // actually crash the server.  So to get something working, we'll
+            // fall back to a Rest Client while still maintaining the RPC Transport stuff
             var info = new Client<User>().Info();
-            var resturl = $"{transport.ServerName()}:{info.RestPort}";
-            ClientFactory.SetClientType(typeof(RestClient<>), InABox.Core.Platform.TimeBench, MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, resturl);
+            if (info.RestPort != 0)
+            {
+                var resturl = $"{transport.ServerName()}:{info.RestPort}";
+                ClientFactory.SetClientType(typeof(RestClient<>), InABox.Core.Platform.TimeBench,
+                    MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, resturl);
+            }
+
             return TransportStatus.OK;
         }