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);
        }
示例#2
0
        public static int Main()
        {
            ICollectionFactory      collectionFactory            = new CollectionFactory();
            ProxyGenerator          proxyGenerator               = new ProxyGenerator();
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            IPofContext                pofContext                = new ClientPofContext();
            IPofSerializer             pofSerializer             = new PofSerializer(pofContext);
            PofStreamsFactory          pofStreamsFactory         = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            var serviceConfiguration = new ClientClusteringConfiguration();
            var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);
            var localEndPoint        = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port);
            var reconnectAttempts    = 10;
            var reconnectDelay       = 1000;
            var serviceClient        = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration);

            if (serviceClient == null)
            {
                Console.Error.WriteLine("Failed to connect to endpoint.");
                return(1);
            }
            else
            {
                var dispatcher = new DispatcherCommand("registered commands");
                dispatcher.RegisterCommand(new ShutdownCommand(serviceClient));
//            dispatcher.RegisterCommand(new ModCommand(serviceClient));
                dispatcher.RegisterCommand(new ExitCommand());
                dispatcher.RegisterCommand(new ServiceCommand(serviceClient));

                var repl = new DargonREPL(dispatcher);
                repl.Run();
                return(0);
            }
        }
示例#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);
        }
示例#5
0
        public static int Main()
        {
            ICollectionFactory collectionFactory = new CollectionFactory();
             ProxyGenerator proxyGenerator = new ProxyGenerator();
             IThreadingFactory threadingFactory = new ThreadingFactory();
             ISynchronizationFactory synchronizationFactory = new SynchronizationFactory();
             IThreadingProxy threadingProxy = new ThreadingProxy(threadingFactory, synchronizationFactory);
             IDnsProxy dnsProxy = new DnsProxy();
             ITcpEndPointFactory tcpEndPointFactory = new TcpEndPointFactory(dnsProxy);
             IStreamFactory streamFactory = new StreamFactory();
             INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
             ISocketFactory socketFactory = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
             INetworkingProxy networkingProxy = new NetworkingProxy(socketFactory, tcpEndPointFactory);
             IPofContext pofContext = new ClientPofContext();
             IPofSerializer pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             var serviceConfiguration = new ClientClusteringConfiguration();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);
             var localEndPoint = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port);
             var reconnectAttempts = 10;
             var reconnectDelay = 1000;
             var serviceClient = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration);
             if (serviceClient == null) {
            Console.Error.WriteLine("Failed to connect to endpoint.");
            return 1;
             } else {
            var dispatcher = new DispatcherCommand("registered commands");
            dispatcher.RegisterCommand(new ShutdownCommand(serviceClient));
            //            dispatcher.RegisterCommand(new ModCommand(serviceClient));
            dispatcher.RegisterCommand(new ExitCommand());
            dispatcher.RegisterCommand(new ServiceCommand(serviceClient));

            var repl = new DargonREPL(dispatcher);
            repl.Run();
            return 0;
             }
        }
示例#6
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);
        }