public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
             processProxy = new ProcessProxy();
             var pofContext = new PofContext().With(x => {
            x.MergeContext(new DspPofContext());
            x.MergeContext(new TrinketsApiPofContext());
            x.MergeContext(new TrinketsImplPofContext());
             });
             ICollectionFactory collectionFactory = new CollectionFactory();
             IFileSystemProxy fileSystemProxy = new FileSystemProxy(streamFactory);
             IThreadingProxy threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
             var dnsProxy = new DnsProxy();
             INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));
             pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             ProxyGenerator proxyGenerator = new ProxyGenerator();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

             // construct libdsp local service node
             ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
             ServiceClient localServiceClient = serviceClientFactory.Construct(clusteringConfiguration);
             keepaliveObjects.Add(localServiceClient);

             temporaryFileService = localServiceClient.GetService<TemporaryFileService>();

             var processInjector = new ProcessInjectorImpl();
             ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);
             processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
             IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
             BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();
             trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
             trinketDtpServerFactory = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
Exemplo n.º 2
0
        private static ServiceClient TryConnectToEndpoint(int reconnectAttempts, int reconnectDelay, ServiceClientFactoryImpl serviceClientFactory, ClientClusteringConfiguration clusteringConfiguration)
        {
            ServiceClient serviceClient = null;

            for (var i = 0; i < reconnectAttempts && serviceClient == null; i++)
            {
                try {
                    serviceClient = serviceClientFactory.Construct(clusteringConfiguration);
                } catch (Exception e) {
                    Console.WriteLine(e);
                    if (i == 0)
                    {
                        Console.Write("Connecting to local endpoint on port " + clusteringConfiguration.Port + ".");
                    }
                    else if (i > 0)
                    {
                        Console.Write(".");
                    }
                    Thread.Sleep(reconnectDelay);
                }
                if (serviceClient != null && i > 0)
                {
                    Console.WriteLine();
                }
            }
            return(serviceClient);
        }
Exemplo n.º 3
0
 private static ServiceClient TryConnectToEndpoint(int reconnectAttempts, int reconnectDelay, ServiceClientFactoryImpl serviceClientFactory, ClientClusteringConfiguration clusteringConfiguration)
 {
     ServiceClient serviceClient = null;
      for (var i = 0; i < reconnectAttempts && serviceClient == null; i++) {
     try {
        serviceClient = serviceClientFactory.Construct(clusteringConfiguration);
     } catch (Exception e) {
        Console.WriteLine(e);
        if (i == 0) {
           Console.Write("Connecting to local endpoint on port " + clusteringConfiguration.Port + ".");
        } else if (i > 0) {
           Console.Write(".");
        }
        Thread.Sleep(reconnectDelay);
     }
     if (serviceClient != null && i > 0) {
        Console.WriteLine();
     }
      }
      return serviceClient;
 }
        public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
            processProxy  = new ProcessProxy();
            var pofContext = new PofContext().With(x => {
                x.MergeContext(new DspPofContext());
                x.MergeContext(new TrinketsApiPofContext());
                x.MergeContext(new TrinketsImplPofContext());
            });
            ICollectionFactory collectionFactory = new CollectionFactory();
            IFileSystemProxy   fileSystemProxy   = new FileSystemProxy(streamFactory);
            IThreadingProxy    threadingProxy    = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
            var dnsProxy = new DnsProxy();
            INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));

            pofSerializer = new PofSerializer(pofContext);
            PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            ProxyGenerator proxyGenerator       = new ProxyGenerator();
            var            serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

            // construct libdsp local service node
            ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
            ServiceClient           localServiceClient      = serviceClientFactory.Construct(clusteringConfiguration);

            keepaliveObjects.Add(localServiceClient);

            temporaryFileService = localServiceClient.GetService <TemporaryFileService>();

            var processInjector = new ProcessInjectorImpl();
            ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);

            processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
            IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
            BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();

            trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
            trinketDtpServerFactory  = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }