Peter 373769682e Add 'submodules/MtProtoKit/' from commit '14ab734b977fd4f1686a2a13415f6a4c9b9fdd6d'
git-subtree-dir: submodules/MtProtoKit
git-subtree-mainline: 3b155750f5a4894ff3dedf1860a37e94e0ea9571
git-subtree-split: 14ab734b977fd4f1686a2a13415f6a4c9b9fdd6d
2019-06-11 18:55:34 +01:00

71 lines
1.3 KiB
Objective-C

#import "MTRequest.h"
#import "MTRpcError.h"
#import <libkern/OSAtomic.h>
@interface MTRequestInternalId : NSObject <NSCopying>
{
NSUInteger _value;
}
@end
@implementation MTRequestInternalId
- (instancetype)init
{
self = [super init];
if (self != nil)
{
static int32_t nextValue = 1;
_value = OSAtomicIncrement32(&nextValue);
}
return self;
}
- (BOOL)isEqual:(id)object
{
return [object isKindOfClass:[MTRequestInternalId class]] && ((MTRequestInternalId *)object)->_value == _value;
}
- (NSUInteger)hash
{
return _value;
}
- (instancetype)copyWithZone:(NSZone *)__unused zone
{
MTRequestInternalId *another = [[MTRequestInternalId alloc] init];
if (another != nil)
another->_value = _value;
return another;
}
@end
@implementation MTRequest
- (instancetype)init
{
self = [super init];
if (self != nil)
{
_internalId = [[MTRequestInternalId alloc] init];
_dependsOnPasswordEntry = true;
}
return self;
}
- (void)setPayload:(NSData *)payload metadata:(id)metadata shortMetadata:(id)shortMetadata responseParser:(id (^)(NSData *))responseParser
{
_payload = payload;
_metadata = metadata;
_shortMetadata = shortMetadata;
_responseParser = [responseParser copy];
}
@end