示例#1
0
        public TrinketDtpServer Create(TrinketStartupConfiguration startupConfiguration)
        {
            var pipeName = DIM_PIPE_NAME_PREFIX + startupConfiguration.TargetProcessId;

            logger.Info("Pipe Name: " + pipeName);

            var rithFactoriesByOpcodes = new Dictionary <byte, Func <uint, RemotelyInitializedTransactionHandler> >();
            var instructionSet         = new DictionaryInstructionSet(rithFactoriesByOpcodes);
            var transportNode          = transportNodeFactory.CreateNode(NodeRole.Server, pipeName, instructionSet.Wrap());
            var wrapper = new TrinketDtpServerImpl(streamFactory, bootstrapConfigurationGenerator, transportNode, startupConfiguration);

            wrapper.Preinitialize(rithFactoriesByOpcodes);
            return(wrapper);
        }
示例#2
0
        public INetworkContext Bootstrap(INetworkBootstrapConfiguration config, IDipNodeFactory dipFactory = null, IDtpNodeFactory dtpFactory = null)
        {
            dipFactory = dipFactory ?? new DefaultDipNodeFactory();
             dtpFactory = dtpFactory ?? new DefaultDtpNodeFactory();

             var node = dtpFactory.CreateNode(config.IsHostRepresentative, config.Namespace, new DipInstructionSet().Wrap());
             var localRouter = dipFactory.CreateLocalRouter(config.RouterConfiguration);
             var hostNetworkNode = dipFactory.CreateLocalhostNetwork(config.HostName, config.HostGuid);
             var globalNetworkNode = dipFactory.CreateGlobalNetwork(config.Namespace);
             globalNetworkNode.PeerChildAsync(hostNetworkNode).Wait();
             hostNetworkNode.PeerChildAsync(localRouter).Wait();

             return new NetworkContext(this, node, globalNetworkNode, hostNetworkNode, localRouter);
        }
        public void TestCreateSession()
        {
            const int processId     = 10;
            var       configuration = CreateMock <DimInstanceContext>();
            var       dtpNode       = CreateUntrackedMock <IDtpNode>();

            When(dtpNodeFactory.CreateNode(Eq(NodeRole.Server), Any <string>(), Any <IEnumerable <IInstructionSet> >())).ThenReturn(dtpNode);

            var session = testObj.CreateSession(processId, configuration);

            AssertEquals(processId, session.ProcessId);
            AssertEquals(configuration, session.Configuration);
            Verify(dtpNodeFactory).CreateNode(Eq(NodeRole.Server), Any <string>(), Any <IEnumerable <IInstructionSet> >(x => x.Count() != 0));
            VerifyNoMoreInteractions();
        }
        public INetworkContext Bootstrap(INetworkBootstrapConfiguration config, IDipNodeFactory dipFactory = null, IDtpNodeFactory dtpFactory = null)
        {
            dipFactory = dipFactory ?? new DefaultDipNodeFactory();
            dtpFactory = dtpFactory ?? new DefaultDtpNodeFactory();

            var node              = dtpFactory.CreateNode(config.IsHostRepresentative, config.Namespace, new DipInstructionSet().Wrap());
            var localRouter       = dipFactory.CreateLocalRouter(config.RouterConfiguration);
            var hostNetworkNode   = dipFactory.CreateLocalhostNetwork(config.HostName, config.HostGuid);
            var globalNetworkNode = dipFactory.CreateGlobalNetwork(config.Namespace);

            globalNetworkNode.PeerChildAsync(hostNetworkNode).Wait();
            hostNetworkNode.PeerChildAsync(localRouter).Wait();

            return(new NetworkContext(this, node, globalNetworkNode, hostNetworkNode, localRouter));
        }