예제 #1
0
 public NamedPipeServer(IFormatter formatter, NamedPipeConfiguration configuration,
                        ILogger <NamedPipeServer> logger)
 {
     _formatter     = formatter;
     _configuration = configuration;
     _logger        = logger;
     Regenerate();
 }
예제 #2
0
        public MessageHandler(IServiceProvider serviceProvider, IMessageChannel messageChannel,
                              NamedPipeConfiguration configuration)
        {
            _serviceProvider = serviceProvider;
            _messageChannel  = messageChannel;
            _configuration   = configuration;

            messageChannel.MessageReceived += MessageChannel_MessageReceived;
        }
예제 #3
0
 public ServerMessageChannel(IFormatter formatter, NamedPipeConfiguration configuration,
                             ILoggerFactory loggerFactory, IConnectedClientFactory connectedClientFactory)
 {
     _configuration          = configuration;
     _connectedClientFactory = connectedClientFactory;
     _logger = loggerFactory.CreateLogger <ServerMessageChannel>();
     for (var i = 0; i < configuration.MaxServerInstances; i++)
     {
         var svr = new NamedPipeServer(formatter, configuration,
                                       loggerFactory.CreateLogger <NamedPipeServer>());
         svr.ClientConnected    += PipeServer_ClientConnected;
         svr.ClientDisconnected += PipeServer_ClientDisconnected;
         _pipeServers.Add(svr);
     }
 }
예제 #4
0
        public static INamedPipeClientBuilder AddNamedPipeClient(this IServiceCollection serviceCollection,
                                                                 string pipeName, Action <NamedPipeConfiguration> configureOptions = null)
        {
            var builder = new NamedPipeClientBuilder(serviceCollection);
            var options = new NamedPipeConfiguration(pipeName);

            configureOptions?.Invoke(options);
            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(options);
            serviceCollection.AddSingleton <IMessageChannel, ClientMessageChannel>();
            serviceCollection.AddSingleton <NamedPipeClient>();
            serviceCollection.AddTransient <IFormatter, BinaryFormatter>();
            serviceCollection.AddScoped <ICallContext, CallContext>();
            serviceCollection.AddTransient <IMethodDispatcher, MethodDispatcher>();
            serviceCollection.AddTransient <IProxyGenerator, ProxyGenerator>();
            serviceCollection.AddTransient(typeof(ContractProxyGenerator <>));

            serviceCollection.AddSingleton <IMessageHandler, MessageHandler>();
            return(builder);
        }
예제 #5
0
 public static IMessageBusOperator AddNamedPipeServer(this IMessageBusOperator @operator)
 {
     NamedPipeConfiguration.ServerInitialize();
     return(@operator);
 }
예제 #6
0
 public NamedPipeClient(NamedPipeConfiguration configuration, IFormatter formatter, ILogger <NamedPipeClient> logger)
 {
     _configuration = configuration;
     _formatter     = formatter;
     _logger        = logger;
 }