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 PeerConnection(ILogger <PeerConnection> logger, IEventBus eventBus, IDateTimeProvider dateTimeProvider, TcpClient connectedClient, PeerConnectionDirection peerConnectionDirection, CancellationToken cancellationToken) { this.logger = logger; this.eventBus = eventBus; this.dateTimeProvider = dateTimeProvider; this.ConnectedClient = connectedClient; this.Direction = peerConnectionDirection; this.cancellationToken = cancellationToken; this.PeerConnectionId = Guid.NewGuid(); this.connectionStateMachine = new PeerConnectionStateMachine(logger, eventBus, this, cancellationToken); }