private async Task ProcessClient(TcpClient client) { logger?.LogInformation("{0} connected", client.Client.RemoteEndPoint); TcpNetworkTransport tcpNetworkTransport = new TcpNetworkTransport(cancellationToken, client, loggerFactory); switch (PerformHandshake(client, tcpNetworkTransport, out string clientId)) { case HandshakeResults.NewClientConnected: InsecureClient insecureClient = new InsecureClient(tcpNetworkTransport, loggerFactory, serializer, orderingService, cancellationToken, sendIdempotencyService, receiveIdempotencyService, delaySequenceGenerator, millisecondsIntervalForPacketResend, keepAliveTimeOut, maximumNumberOfKeepAliveMisses, keepAliveResponseTimeOut); clients.TryAdd(clientId, insecureClient); await tcpNetworkTransport.SendData(Encoding.Unicode.GetBytes(Id)); OnClientConnected?.Invoke(insecureClient); break; case HandshakeResults.ExsistingClientReconnected: clients[clientId].ClientReconnected(tcpNetworkTransport); await tcpNetworkTransport.SendData(Encoding.Unicode.GetBytes(Id)); break; case HandshakeResults.HandshakeFailed: tcpNetworkTransport.DropConnection(); client.Close(); client.Dispose(); break; } }
internal InsecureClient(TcpNetworkTransport tcpNetworkTransport, ILoggerFactory loggerFactory, ISerializer serializer, IOrderingService orderingService, CancellationToken cancellationToken, ISendIdempotencyService <Guid, Packet> sendIdempotencyService, IReceiveIdempotencyService <string> receiveIdempotencyService, ISequenceGenerator delaySequenceGenerator, int millisecondsIntervalForPacketResend, int keepAliveTimeOut, int maximumNumberOfKeepAliveMisses, int keepAliveResponseTimeOut) { Init(loggerFactory, serializer, orderingService, cancellationToken, sendIdempotencyService, receiveIdempotencyService, delaySequenceGenerator, millisecondsIntervalForPacketResend, tcpNetworkTransport, keepAliveTimeOut, maximumNumberOfKeepAliveMisses, keepAliveResponseTimeOut); }