IAuthKeyNegotiator IMTProtoClientBuilder.BuildAuthKeyNegotiator(IClientTransportConfig clientTransportConfig)
 {
     return new AuthKeyNegotiator(clientTransportConfig,
         this,
         _tlRig,
         _nonceGenerator,
         _hashServices,
         _encryptionServices,
         _keyChain);
 }
        public IClientTransport CreateTransport(IClientTransportConfig clientTransportConfig)
        {
            // TCP.
            var tcpTransportConfig = clientTransportConfig as TcpClientTransportConfig;
            if (tcpTransportConfig != null)
            {
                return new TcpClientTransport(tcpTransportConfig);
            }

            throw new NotSupportedException(string.Format("Transport type '{0}' is not supported.", clientTransportConfig.TransportName));
        }
        public TelegramClient(IClientTransportConfig transportConfig,
            ConnectionConfig connectionConfig,
            TelegramAppInfo appInfo,
            IMTProtoClientBuilder builder = null)
        {
            if (builder == null)
            {
                builder = MTProtoClientBuilder.Default;
            }

            _transportConfig = transportConfig;
            _appInfo = appInfo;
            _connection = builder.BuildConnection(_transportConfig);
            _connection.Configure(connectionConfig);
            _methods = new TelegramAsyncMethods(_connection);
        }
 public AuthKeyNegotiator(
     [NotNull] IClientTransportConfig clientTransportConfig,
     [NotNull] IMTProtoClientBuilder mtProtoBuilder,
     [NotNull] TLRig tlRig,
     [NotNull] INonceGenerator nonceGenerator,
     [NotNull] IHashServices hashServices,
     [NotNull] IEncryptionServices encryptionServices,
     [NotNull] IKeyChain keyChain)
 {
     _clientTransportConfig = clientTransportConfig;
     _mtProtoBuilder = mtProtoBuilder;
     _tlRig = tlRig;
     _nonceGenerator = nonceGenerator;
     _hashServices = hashServices;
     _encryptionServices = encryptionServices;
     _keyChain = keyChain;
 }
 IMTProtoClientConnection IMTProtoClientBuilder.BuildConnection(IClientTransportConfig clientTransportConfig)
 {
     return new MTProtoClientConnection(clientTransportConfig, _clientTransportFactory, _tlRig, _messageIdGenerator, _messageCodec);
 }