title: Setting proxy with tlsharp
body: <p>I'm trying to send messages using Telegram and TLSharp and that's what i've got so far:</p>
  
  <pre><code>static async void MainAssincrono(string[] args)
          {
              IniciarVariaveis();
  
              TelegramClient client;
              TcpClient tcp = conectarProxy(httpProxyHost, httpProxyPort);
              client = new TelegramClient(appId, appHash);
              await client.ConnectAsync();
  
              if (habilitarClient)
              {
                  var hashAuth = await client.SendCodeRequestAsync(apiPhone);
                  Console.WriteLine("Digite o código recebido no telegram do celular: ");
                  var code = Console.ReadLine();
                  var user = await client.MakeAuthAsync(apiPhone, hashAuth, code);
              }
              else
              {
                  var resultado = await client.GetContactsAsync();
                  var user = resultado.users.lists.Where(x =&gt; x.GetType() == typeof(TLUser)).Cast&lt;TLUser&gt;().FirstOrDefault(x =&gt; x.phone == "5581971126655");
                  await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "Teste");
              }
  </code></pre>
  
  <p>It works but i'm trying to set up a proxy. And here's what i'm trying to do:</p>
  
  <pre><code>TcpClient tcp = conectarProxy(httpProxyHost, httpProxyPort);
              client = new TelegramClient(appId, appHash, null, null, new TcpClientConnectionHandler(tcp);
  
  private static TcpClient conectarProxy(string httpProxyHost, int httpProxyPort)
          {
              var url = "http://" + httpProxyHost + ":" + httpProxyPort;
              var proxyUrl = WebRequest.DefaultWebProxy.GetProxy(new Uri(url));
              WebResponse response = null;
              var tentativas = 10;
  
              while (tentativas &gt;= 0)
              {
                  var request = (HttpWebRequest)WebRequest.Create(url);
                  request.KeepAlive = true;
                  var webProxy = new WebProxy(proxyUrl);
                  request.Proxy = webProxy;
                  request.Method = "CONNECT";
                  request.Timeout = 3000;
  
                  tentativas--;
                  try
                  {
                      response = request.GetResponse();
                      break;
                  }
                  catch (Exception ex)
                  {
                      if (tentativas &gt;= 0 &amp;&amp; ex.Message.Equals("The operation has timed out", StringComparison.InvariantCultureIgnoreCase))
                      {
                          Console.WriteLine("Ocorreu timeout ao tentar se conectar pelo proxy.");
                      }
                      else
                      {
                          throw new Exception("Algo deu errado", ex);
                      }
                  }
              }
              var responseStream = response.GetResponseStream();
              Debug.Assert(responseStream != null);
  
              const BindingFlags Flags = BindingFlags.NonPublic | BindingFlags.Instance;
  
              var rsType = responseStream.GetType();
              var connectionProperty = rsType.GetProperty("Connection", Flags);
  
              var connection = connectionProperty.GetValue(responseStream, null);
              var connectionType = connection.GetType();
              var networkStreamProperty = connectionType.GetProperty("NetworkStream", Flags);
  
              var networkStream = networkStreamProperty.GetValue(connection, null);
              var nsType = networkStream.GetType();
              var socketProperty = nsType.GetProperty("Socket", Flags);
              var socket = (Socket)socketProperty.GetValue(networkStream, null);
  
              return new TcpClient { Client = socket };
          }
  </code></pre>
  
  <p>The signature says that it's expecting a TcpClientConnectionHandler as a parameter but if i pass a TcpClientConnectionHandler like this:</p>
  
  <pre><code>client = new TelegramClient(appId, appHash, null, null, new TcpClientConnectionHandler(tcp));
  </code></pre>
  
  <p>I gives an error saying that it's tpc is a variable but it's being used as a method. What am i doing wrong?</p>