Beispiel #1
0
 public TLClient Connect()
 {
     try
     {
         FakeSessionStore session = new FakeSessionStore();
         TLClient         client  = new TLClient(api_id, api_hash, session, "session");
         var t = Task.Run(() => client.ConnectAsync());
         t.Wait();
         return(client);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Beispiel #2
0
 public ClientService(string phone)
 {
     if (CheckLimit().Result)
     {
         try
         {
             var store = new FileSessionStore();
             client = new TLClient(ApiId, ApiHash, store, phone);
             var t = Task.Run(() => client.ConnectAsync());
             t.Wait();
         }
         catch (FloodException flood)
         {
             SetLimit(Convert.ToInt32(flood.TimeToWait)).Wait();
             Thread.Sleep(flood.TimeToWait);
             new ClientService(phone);
         }
         catch (Exception ex)
         {
             Trace.TraceError(ex.InnerException.Message);
         }
     }
 }