no message

This commit is contained in:
Peter 2015-04-13 19:24:03 +03:00
parent 5c710b85a7
commit db6190e9e9
6 changed files with 33 additions and 9 deletions

View File

@ -26,6 +26,9 @@
#define IPHONE_4_NAMESTRING @"iPhone 4"
#define IPHONE_4S_NAMESTRING @"iPhone 4S"
#define IPHONE_5_NAMESTRING @"iPhone 5"
#define IPHONE_5S_NAMESTRING @"iPhone 5S"
#define IPHONE_6_NAMESTRING @"iPhone 6"
#define IPHONE_6Plus_NAMESTRING @"iPhone 6 Plus"
#define IPHONE_UNKNOWN_NAMESTRING @"Unknown iPhone"
#define IPOD_1G_NAMESTRING @"iPod touch 1G"
@ -67,6 +70,9 @@ typedef enum {
UIDevice4iPhone,
UIDevice4SiPhone,
UIDevice5iPhone,
UIDevice5SiPhone,
UIDevice6iPhone,
UIDevice6PlusiPhone,
UIDevice1GiPod,
UIDevice2GiPod,
@ -137,6 +143,9 @@ typedef enum {
case UIDevice4iPhone: return IPHONE_4_NAMESTRING;
case UIDevice4SiPhone: return IPHONE_4S_NAMESTRING;
case UIDevice5iPhone: return IPHONE_5_NAMESTRING;
case UIDevice5SiPhone: return IPHONE_5S_NAMESTRING;
case UIDevice6iPhone: return IPHONE_6_NAMESTRING;
case UIDevice6PlusiPhone: return IPHONE_6Plus_NAMESTRING;
case UIDeviceUnknowniPhone: return IPHONE_UNKNOWN_NAMESTRING;
case UIDevice1GiPod: return IPOD_1G_NAMESTRING;
@ -185,6 +194,10 @@ typedef enum {
if ([platform hasPrefix:@"iPhone3"]) return UIDevice4iPhone;
if ([platform hasPrefix:@"iPhone4"]) return UIDevice4SiPhone;
if ([platform hasPrefix:@"iPhone5"]) return UIDevice5iPhone;
if ([platform hasPrefix:@"iPhone6,1"]) return UIDevice5SiPhone;
if ([platform hasPrefix:@"iPhone6,2"]) return UIDevice5SiPhone;
if ([platform hasPrefix:@"iPhone7,1"]) return UIDevice6PlusiPhone;
if ([platform hasPrefix:@"iPhone7,2"]) return UIDevice6iPhone;
// iPod
if ([platform hasPrefix:@"iPod1"]) return UIDevice1GiPod;

View File

@ -539,6 +539,11 @@ typedef enum {
bool success = [self isResponseValid:data];
#ifdef DEBUG
//if (!success)
// NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
#endif
httpWorker.delegate = nil;
[self _removeActiveConnection:httpWorker];

View File

@ -268,11 +268,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64;
{
MTTransport *transport = nil;
#if TARGET_IPHONE_SIMULATOR && false
transport = [[MTHttpTransport alloc] initWithDelegate:self context:_context datacenterId:_datacenterId address:[_context addressSetForDatacenterWithId:_datacenterId].addressList.firstObject];
#else
transport = [_transportScheme createTransportWithContext:_context datacenterId:_datacenterId delegate:self];
#endif
[self setTransport:transport];
}

View File

@ -19,6 +19,7 @@
@property (nonatomic, strong) MTRequestErrorContext *errorContext;
@property (nonatomic) bool hasHighPriority;
@property (nonatomic) bool dependsOnPasswordEntry;
@property (nonatomic) bool passthroughPasswordEntryError;
@property (nonatomic, copy) void (^completed)(id result, NSTimeInterval completionTimestamp, id error);
@property (nonatomic, copy) void (^progressUpdated)(float progress, NSUInteger packetLength);

View File

@ -13,5 +13,6 @@
@property (nonatomic) MTAbsoluteTime minimalExecuteTime;
@property (nonatomic) NSUInteger internalServerErrorCount;
@property (nonatomic) NSUInteger floodWaitSeconds;
@end

View File

@ -472,9 +472,12 @@
if (errorCode == 401)
{
if ([errorText rangeOfString:@"SESSION_PASSWORD_NEEDED"].location != NSNotFound)
{
if (!request.passthroughPasswordEntryError)
{
[_context updatePasswordInputRequiredForDatacenterWithId:mtProto.datacenterId required:true];
}
}
else
{
id<MTRequestMessageServiceDelegate> delegate = _delegate;
@ -494,7 +497,7 @@
request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + 2.0);
}
}
else if (errorCode == 420)
else if (errorCode == 420 || [errorText rangeOfString:@"FLOOD_WAIT_"].location != NSNotFound)
{
if (request.errorContext == nil)
request.errorContext = [[MTRequestErrorContext alloc] init];
@ -508,11 +511,16 @@
[scanner scanString:@"FLOOD_WAIT_" intoString:nil];
if ([scanner scanInt:&errorWaitTime])
{
if (request.shouldContinueExecutionWithErrorContext != nil && request.shouldContinueExecutionWithErrorContext(request.errorContext))
request.errorContext.floodWaitSeconds = errorWaitTime;
if (request.shouldContinueExecutionWithErrorContext != nil)
{
if (request.shouldContinueExecutionWithErrorContext(request.errorContext))
{
restartRequest = true;
request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (MTAbsoluteTime)errorWaitTime);
}
}
else
{
restartRequest = true;