123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using InABox.Clients;
- using InABox.Core;
- using InABox.Rpc;
- using PRSServices;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PRSServer;
- public abstract class DatabaseProxyEngine<TProperties> : Engine<TProperties>
- where TProperties : DatabaseProxyProperties
- {
- public override void Run()
- {
- Logger.Send(LogType.Information, "", "Starting..");
- if (string.IsNullOrWhiteSpace(Properties.Server))
- {
- Logger.Send(LogType.Error, "", "Server is blank!");
- return;
- }
- var transport = new RpcClientPipeTransport(DatabaseServerProperties.GetPipeName(Properties.Server, true));
- ClientFactory.SetClientType(typeof(RpcClient<>), Platform.LicensingEngine, Version, transport);
- CheckConnection();
- RunProxy();
- }
- protected abstract void RunProxy();
- private void CheckConnection()
- {
- // Wait for server connection
- while (!Client.Ping())
- {
- Logger.Send(LogType.Error, "", "Database server unavailable. Trying again in 30 seconds...");
- Task.Delay(30_000).Wait();
- Logger.Send(LogType.Information, "", "Retrying connection...");
- }
- ClientFactory.SetBypass();
- }
- }
|