Commit graph

134 commits

Author SHA1 Message Date
salar2k fc09dba71b Implementing IDisposable 2016-12-16 10:25:33 +03:30
unn4m3d 545e736808 Catch PhoneMigrationException in IsPhoneRegisteredAsync 2016-11-27 19:37:15 +10:00
Afshin Arani 6f9c328349 Add Cloud Password Support 2016-11-16 17:01:00 +03:30
Eugene Timokhov 8b2f227142 Added possibility to do ping request (SendPingAsync method) 2016-11-07 02:40:19 +03:00
Andres G. Aragoneses 5e9bb6163f Throw FloodException instead of calling Thread.Sleep()
Doing this is better when looking at the problem from at least
these 2 points of view:

a) You're working on TLSharp itself: You might be testing some
new things or running TLSharp's tests. Suddenly, if a FLOOD_WAIT
response happens, there's no clear way to know. You just see the
tests taking forever. But if a test has reached a situation in
which Telegram has returned a FLOOD_WAIT error, it's very likely
that what happens is that the TLSharp operation being tested is
actually buggy, which means that the test should FAIL FAST and
show a stacktrace of the problem so that you can see where in the
code was the FLOOD_WAIT received/caused. You shouldn't need to
kill the run of the test suite and hope to hit the problem again
only when you were using the debugger (to be able to pause
execution and examine a stacktrace of where the execution flow is).

b) You're using TLSharp: if you hit a FLOOD_WAIT problem it may
happen because:

b1) TLSharp has a bug: in this case it's better to throw an
exception so that the user can copy the stacktrace and paste
it into a new Github issue.

b2) Your program uses TLSharp sending excessive requests: you
want to have your program know when you hit the limit, to be
able to fix your program to not be so floody. But a call to
Thread.Sleep() doesn't help you to know this, you just know
that suddenly your program has hung, and you don't know why.
You cannot react to the problem, however with an exception you
can react to the problem (for example by examining the time
that the exception provides, as a TimeSpan property, to know
how much your program needs to wait to be able to use TLSharp
again).
2016-11-01 23:52:58 +08:00
Ilya Pirozhenko 24a9ea1ed9 Merge pull request #277 from knocte/friendlerAuthTestFailures
Friendlier exceptions for Auth testing
2016-10-31 11:12:36 +03:00
Andres G. Aragoneses f062c0a7a1 Friendlier exceptions for Auth testing
This change also lets you write the auth code in the
app.config file without the need to recompile/debug.
2016-10-31 00:17:03 +08:00
Andres G. Aragoneses 34e89f3f37 Require some parameters as non empty & not null before proceeding 2016-10-30 23:34:44 +08:00
Andres G. Aragoneses a029c33e34 TelegramClient ctor: move null checks earlier
This way we avoid creating a FileSessionStore object
or initializing the TLContext if API credentials are
not supplied, to be on the safe side.
2016-10-30 23:34:33 +08:00
Andres G. Aragoneses 5161d38456 MigrationExceptions: update URL
Previous commit[1] made the anchor change its name due to
changing slightly the content of the README around the
MIGRATE problem.

[1] e1ff4bb75b
2016-10-30 16:33:29 +08:00
Andres G. Aragoneses e1ff4bb75b Bring back report message to Migration exceptions
When refactoring recently the PHONE_MIGRATE_X error
wrt exception handling [1] I removed the dubious/obsolete
"settings" part, but I mistakenly removed the URL which
tells library consumers that if they face this exception,
it's actually a bug of the library that they should report.

[1] 77867b44e6
2016-10-30 16:16:55 +08:00
Andres G. Aragoneses a521466bb0 Create common abstract DataCenterMigrationException
We can abstract the DC property to a common abstract class
so have a bit of less code and we join these 3 classes together
semantically.
2016-10-30 16:04:32 +08:00
Andres G. Aragoneses c1305ada65 Rename MigrationNeededException to PhoneMigrationException
There are different kind of MIGRATE errors that could be
thrown by the Telegram API, as evidenced by this recent
change:
b06f8a8e11

So this rename tries to make it consistent to the new
exception names:
* FILE_MIGRATE_x -> FileMigrationException
* USER_MIGRATE_y -> UserMigrationException
* PHONE_MIGRATE_z -> PhoneMigrationException
2016-10-30 15:57:45 +08:00
Ilya P d692196dce another fix 2016-10-29 17:13:28 +03:00
Ilya P 58d83cfcfe Path fix 2016-10-29 17:05:40 +03:00
Ilya P 46694e2406 Moved nuspec to a proper place 2016-10-29 15:34:01 +03:00
Ilya P b06f8a8e11 Added File-Migrate feature 2016-10-29 11:47:18 +03:00
Afshin Arani 8c2cab48f4 Change TLDialogs to TLAbsDialogs 2016-10-26 20:13:19 +03:30
Andres G. Aragoneses c644bac4e4 Fix typo in string of exception message
This was meant to start with $, not including
the $ char inside the string, otherwise the
compiler string interpolation doesn't work.
2016-10-24 14:57:04 +08:00
Andres G. Aragoneses 0e32291d11 Tests: show a more meaningful exception when running for 1st time
Instead of throwing a System.FormatException, capture the URL
thrown by the library itself so that the developer configures
the API_ID and API_HASH and places them in the app.config file.
2016-10-23 23:23:10 +08:00
Ilya P b823c34078 Move upload helper to helpers 2016-10-23 14:12:34 +03:00
Ilya P f6ad50ce94 - added getFile method 2016-10-23 13:29:18 +03:00
Ilya P 1d6035aeb7 - fix file Uploader
- refactor file uploader
- added test for file uploading
2016-10-23 13:02:44 +03:00
Ilya P 7fd0413c7e - removed non-generic TLVector
- write length of Vector during Serialization
2016-10-23 11:17:59 +03:00
Ilya P f40034ad09 Merge remote-tracking branch 'refs/remotes/origin/master' into pr/250
# Conflicts:
#	TLSharp.Core/TLSharp.Core.csproj
2016-10-23 11:06:00 +03:00
Ilya Pirozhenko 1b90e64ec5 Merge pull request #255 from knocte/netFrameworkVersion
build: switch to lower framework version (4.5.2 -> 4.5)
2016-10-23 10:56:51 +03:00
Andres G. Aragoneses 77867b44e6 Use better exception handling
Parsing the message of an exception to decide what to do
next is a bad practice, because it's easy that the message
might be changed by mistake in the future. To enforce the
coupling in a stronger way it's better to use exceptions
of different type depending on the kind of error, so that
we rely on the compiler enforcing the behaviour when doing
changes in this error handling areas in the future.

This also makes the code a bit more simple and readable.
2016-10-22 22:00:15 +08:00
Andres G. Aragoneses b129e655f8 build: switch to lower framework version (4.5.2 -> 4.5)
This change is good because:
a) It's better to target a lower target framework version if
the project doesn't necessarily depend on the new features
of the newer versions (so, bigger target audience).
b) It lets compile the project with implementations of the
.NET Framework that are not compatible with 4.5.2. For example,
after this change I can successfully build TLSharp with the
Mono v4.2.1 that comes in my Ubuntu Linux 16.04.1.
2016-10-21 23:58:21 +08:00
Afshin Arani 7d436e3954 Merge pull request #1 from sochix/master
Ilya's Works
2016-10-16 21:22:44 +03:30
Ilya P 40c1725e41 - Layer 53
- Fix bug in generator
- Fix DC switching
- change default server
2016-10-15 13:35:54 +03:00
Afshin Arani a20a73f29f Remove GC.Collect() 2016-10-14 11:48:06 +03:30
Afshin Arani 79b02b9295 Upload Helper 2016-10-14 11:45:33 +03:30
Ilya P 066e9cacfe - Updated README 2016-10-11 17:31:30 +03:00
Ilya P 0351c0f1df Add AsyncSuffix to methods 2016-10-11 16:32:38 +03:00
Ilya P 2ffa954246 Fixes 2016-10-11 16:28:57 +03:00
Afshin Arani 6af7c66a81 Redesign Everything 2016-09-24 17:08:26 +03:30
Afshin Arani b5472c6cd7 Add DownloadFileRequest Class 2016-09-22 17:09:56 +03:30
Afshin Arani 1c2e354967 Update Everything 2016-09-22 17:01:59 +03:30
steavy29 78e3a7794f Merge fix. 2016-09-14 14:57:07 +03:00
Ilya Pirozhenko 8411235fe1 Merge branch 'pr/203'
Conflicts:
	README.md
	TLSharp.Core/TelegramClient.cs
	TLSharp.Tests/TLSharpTests.cs
2016-09-13 22:24:00 +03:00
Ilya Pirozhenko 148828edc1 Merge branch 'pr/198'
Conflicts:
	TLSharp.Tests/TLSharpTests.cs
2016-09-13 22:17:31 +03:00
steavy29 1c31794751 Added GetUpdatesDifference and GetUpdatesState functions implementations. 2016-09-13 13:34:32 +03:00
Ilya Pirozhenko d6331c2352 Merge pull request #196 from steavy29/signup-impl
Added SignUp implementation.
2016-09-11 14:58:16 +03:00
steavy29 ccf2008404 Added implementation of AddChatUser/DeleteChatUser/LeaveChat 2016-09-09 19:56:47 +03:00
steavy29 98f014a49d Implemented CreateChat. Fixed MessageServiceConstructor - migrated it from api layer level 16 to 23. 2016-09-08 14:35:25 +03:00
steavy29 c48109eee3 Added SignUp implementation. 2016-09-06 18:37:05 +03:00
steavy29 f98540bd7f Changed session store to return null when couldn't load instead of exception. 2016-09-06 18:20:06 +03:00
David Woakes 089f80fcce Add contacts.GetContacts method to client 2016-07-21 06:57:15 +01:00
David Woakes 397f20298e Fix spelling of Receive 2016-07-20 08:15:28 +01:00
David Woakes 15a51818f9 Fix spelling of Receive 2016-07-20 08:09:27 +01:00
David Woakes 7c8d5e089e Make line endings consistent (LF) 2016-07-20 07:26:55 +01:00
David Woakes 8026bd79dc Fix issues with GetDialogs
Default value of max_id = 0 returns all dialogs
Should return a class with lists of dialog, messages, chats and users.
Add UserForeignConstructor to list of constructors
Add missing detail to DialogConstructor (PeerNotifySettings)
Unpack datastream completely to avoid issue with Ionic exception causing
problems in userForeign parsing
Use more recent code for Dialog construction
2016-07-19 14:47:08 +01:00
Ilya Pirozhenko b869a4f617 Merge pull request #156 from Starli0n/master
Add GetFile() method
2016-06-27 17:23:37 +03:00
eaba ac05172359 Merge pull request #2 from chusothe41/master
UserFullConstructor : UserFull no accepts self id.
2016-05-23 15:07:44 +01:00
Jesus 6365297aaf UserFullConstructor : UserFull no accepts self id.
Added test method to GetUserFull
Added info to README.md
2016-05-18 12:55:22 +02:00
Starli0n ee4fbef8a9 Add GetFile() method 2016-05-17 14:22:14 +02:00
eaba a2669bfe1a Add files via upload 2016-05-16 09:28:42 +01:00
eaba 9d69d4881b Update TLSharp.Core.csproj 2016-05-16 09:28:09 +01:00
eaba ad94224fb5 Add files via upload 2016-05-16 09:25:07 +01:00
Jesus 5120b77b81 All classes that inherit from User and need "username" property have it.
UserFullConstructor Read changed to not to parse User (by default it parses a UserSelfConstructor, now uses UserRequestConstructor).
In Dictionary UserContactConstructor was signed with 0xf2fb8319 now 0xcab35e18 (That is the real one given by Telegram)
2016-05-13 10:58:25 +02:00
ahmadali shafiee 23404f751d argument change
it looks better
2016-04-21 15:30:40 +04:30
ahmadali shafiee 4a44709150 get apiHash and apiId in the constructor 2016-04-18 15:35:30 +04:30
ahmadali shafiee 504b63a6d7 formatting code (ctrl + k + d) 2016-04-18 15:20:57 +04:30
Ilya Pirozhneko 103e41fb2b Updates 2016-02-07 13:28:41 +03:00
Ilya Pirozhneko 84cbe0afc8 Updated readme 2016-02-04 17:05:48 +03:00
Ilya Pirozhneko 69700fdad0 Small improvements 2016-02-04 16:04:31 +03:00
Ilya Pirozhneko 9cc6942088 Added tests and fixes to SendMediaFunctionality and GetHistory 2016-02-03 22:36:39 +03:00
Ilya Pirozhneko c77cfc064d Add by userName 2016-02-01 23:58:51 +03:00
Ilya Pirozhneko 1dce594e43 - Update layer to 23
- Start implementing get user by userName
2016-02-01 23:39:39 +03:00
Ilya Pirozhneko e281f281dd Improved import contact method 2016-02-01 23:06:15 +03:00
Ilya Pirozhneko 824ba77e12 Added auto dc switching 2016-01-27 14:02:18 +03:00
Ilya Pirozhenko f56ffc7c6f Merge pull request #65 from siml173/master
new completed method.
2016-01-21 11:51:00 +03:00
ra0o0f 7e18b68d72 UploadFile and SendMediaMessage 2016-01-17 12:46:44 +03:30
mohammad ahmady 7236cf4286 Create ImportContactRequest 2016-01-16 12:23:15 +03:30
mohammad ahmady c7dbaaca73 Create GetContactRequest 2016-01-16 12:21:52 +03:30
mohammad ahmady a7893c6d0d Create DeleteChatUserRequest 2016-01-16 12:20:32 +03:30
mohammad ahmady 25e1015e82 Merge pull request #1 from siml173/siml173-patch-1
Create AddChatUserRequest
2016-01-16 12:19:43 +03:30
mohammad ahmady 8df066aadc Create CreateChatRequest 2016-01-16 12:18:59 +03:30
mohammad ahmady 02d6e2b3af Create AddChatUserRequest 2016-01-16 12:13:24 +03:30
ra0o0f dbe369b26d change how client receive tcp packets 2016-01-09 14:35:00 +03:30
Zero Dwide 79399df6fc bug fixed: users list size set wrong
var result was vector length, but again in next two lines, users_len used to set vector lenght, which was part of bytes related to parsing users.
according to https://core.telegram.org/method/users.getUsers :

first read => vector signature
second read => vector length
third + read  => loop for parsing users
2015-11-06 20:42:13 +03:30
Lonami dcdb2405b5 More requests added
More requests added:
- GetDialogsRequest
- GetFileRequest
- GetHistoryRequest
- GetNearestDcRequest
- GetUsersRequest
2015-10-14 18:16:27 +02:00
Ilya Pirozhneko b0a824988d Add proper exception messages 2015-10-01 20:55:02 +08:00
Ilya Pirozhneko 3bb487a194 TLSharp and Tests 2015-09-28 10:01:17 +08:00