Exemple #1
0
        public void SetUp()
        {
            Configurator.Configure();
            _connectionListener = new LidgrenServerConnectionListener(_applicationId, _listenAddress, _port, new BinaryMessageSerializer(), new UnencryptedCryptoProviderResolver());

            _dispatcher = new OperationDispatcher();
            _dispatcher.RegisterHandler <ICalculator>(new Calculator());
            _dispatcher.RegisterHandler <IGreeter>(new Greeter());

            _server = new GenericServerEndpoint(_connectionListener, new ServerConfig(), () => _dispatcher);
            _server.Start();
        }
        private void RegisterHandlers()
        {
            _operationDispatcher.RegisterHandler <CreateNewStream>(new CreateNewStreamHandler(async doc => await _cosmosClient.CreateItemAsync(doc, _cosmosDBConfigurations.StreamContainerName)));

            _operationDispatcher.RegisterHandler <GetStreamDocumentByIdAsync>(new GetStreamDocumentByIdAsyncHandler(_cosmosClient, _cosmosDBConfigurations));

            _operationDispatcher.RegisterHandler <ReadStreamWithEventsByDirection>(new ReadStreamWithEventsByDirectionHandler(async opt => await _operationDispatcher.Dispatch <GetStreamDocumentByIdAsync, Optional <StreamDocument> >(opt).ConfigureAwait(false)));

            _operationDispatcher.RegisterHandler <GetEventDocumentsForward>(new GetEventDocumentsForwardHandler(_cosmosClient, _cosmosDBConfigurations));

            _operationDispatcher.RegisterHandler <AppendToStreamAsync>(new AppendToStreamAsyncHandler(_eventSerializer, _cosmosClient, _cosmosDBConfigurations, _operationDispatcher));

            _operationDispatcher.RegisterPipeline <AppendToStreamAsync>(new AppendToStreamAsyncPipeline());
        }
        private IServerEndpoint CreateServer(ILidgrenCryptoProviderResolver providerResolver)
        {
            DefaultConfig.MessageSerializer     = new BinaryMessageSerializer();
            DefaultConfig.MessageFactory        = new DefaultMessageFactory();
            DefaultConfig.RemoteExecutorFactory = new RemoteExecutorFactory();
            DefaultConfig.TaskScheduler         = new AsyncTaskScheduler();
            TransportLayerResolver.Register(new LidgrenProvider(providerResolver));
            _connectionListener = new LidgrenServerConnectionListener(_applicationId, _listenAddress, _port, new BinaryMessageSerializer(), providerResolver);

            _dispatcher = new OperationDispatcher();
            _dispatcher.RegisterHandler <ICalculator>(new Calculator());
            _dispatcher.RegisterHandler <IGreeter>(new Greeter());

            IServerEndpoint server = new GenericServerEndpoint(_connectionListener, new ServerConfig(), () => _dispatcher);

            server.Start();
            return(server);
        }
Exemple #4
0
        public void Should_register_request_handler()
        {
            var foo = MockRepository.GenerateMock <IFoo>();

            _subject.RegisterHandler(typeof(IFoo), foo);

            _messageDispatcher.AssertWasCalled(m => m.Register(Arg <RequestHandler> .Matches(h =>
                                                                                             h.InterfaceType == typeof(IFoo) &&
                                                                                             h.Handler == foo &&
                                                                                             h.HandledMessageType == typeof(IFoo).Name &&
                                                                                             h.HandlerGroupId == typeof(IFoo).GUID)));
        }
        public void ValidateIpEndPointProvision()
        {
            connectionListener = new LidgrenServerConnectionListener(applicationId, ListenAddress, Port, new BinaryMessageSerializer(), new UnencryptedCryptoProviderResolver());
            dispatcher         = new OperationDispatcher();
            IPEndPoint senderEndPoint = null;
            IPEndPoint clientEndPoint = null;

            dispatcher.RegisterHandler <IEndPointProvisioner>(new EndPointProvisioner {
                OnStuff = e => senderEndPoint = e
            });
            server = new GenericServerEndpoint(connectionListener, new ServerConfig(), () => dispatcher);
            server.Start();

            using (ClientConnection client = CreateClientConnection())
            {
                client.Open();
                clientEndPoint = client.GetClientEndpoint();
                client.RemoteExecutor.Create <IEndPointProvisioner>().DoStuff(null);
            }
            server.Dispose();
            Assert.AreEqual(clientEndPoint, senderEndPoint);
        }