public PeerConnection(ILogger <PeerConnection> logger,
                              IEventBus eventBus,
                              TcpClient connectedClient,
                              PeerConnectionDirection peerConnectionDirection,
                              IPeerContextFactory peerContextFactory,
                              NetworkMessageDecoder networkMessageDecoder,
                              INetworkMessageProcessorFactory networkMessageProcessorFactory,
                              CancellationToken cancellationToken)
        {
            this.logger                         = logger;
            this.eventBus                       = eventBus;
            this.ConnectedClient                = connectedClient;
            this.Direction                      = peerConnectionDirection;
            this.peerContextFactory             = peerContextFactory;
            this.networkMessageDecoder          = networkMessageDecoder;
            this.networkMessageProcessorFactory = networkMessageProcessorFactory;
            this.cancellationToken              = cancellationToken;

            this.PeerContext = this.peerContextFactory.Create(
                PeerConnectionDirection.Inbound,
                Guid.NewGuid().ToString(),
                connectedClient.Client.LocalEndPoint,
                connectedClient.Client.RemoteEndPoint,
                this);

            this.networkMessageDecoder.SetPeerContext(this.PeerContext);

            this.connectionStateMachine = new PeerConnectionStateMachine(logger, eventBus, this, networkMessageDecoder, networkMessageProcessorFactory, cancellationToken);
        }
 public MithrilForgeClientConnectionHandler(ILogger <MithrilForgeClientConnectionHandler> logger,
                                            IServiceProvider serviceProvider,
                                            IEventBus eventBus,
                                            INetworkMessageProcessorFactory networkMessageProcessorFactory,
                                            IPeerContextFactory peerContextFactory)
 {
     _logger          = logger;
     _serviceProvider = serviceProvider;
     _eventBus        = eventBus;
     _networkMessageProcessorFactory = networkMessageProcessorFactory;
     _peerContextFactory             = peerContextFactory;
 }
 public PeerConnectionFactory(ILoggerFactory loggerFactory,
                              IEventBus eventBus,
                              IPeerContextFactory peerContextFactory,
                              INetworkDefinition chainDefinition,
                              INetworkMessageProcessorFactory networkMessageProcessorFactory,
                              INetworkMessageSerializerManager networkMessageSerializerManager)
 {
     this.loggerFactory                   = loggerFactory;
     this.eventBus                        = eventBus;
     this.peerContextFactory              = peerContextFactory;
     this.chainDefinition                 = chainDefinition;
     this.networkMessageProcessorFactory  = networkMessageProcessorFactory;
     this.networkMessageSerializerManager = networkMessageSerializerManager;
     this.logger = loggerFactory.CreateLogger <PeerConnectionFactory>();
 }