MTResendMessageService
protocol
MTResendMessageServiceDelegate
- (void)resendMessageServiceCompleted:(MTResendMessageService *)resendService;
class
MTResendMessageService:
MTMessageService
@property (nonatomic, readonly) int64_t messageId;
@property (nonatomic, weak) id<MTResendMessageServiceDelegate> delegate;
// prepare MTMessageTransaction
- (MTMessageTransaction *)mtProtoMessageTransaction:(MTProto *)mtProto
{
if (_currentRequestMessageId == 0 || _currentRequestTransactionId == nil)
{
_currentRequestTransactionId = nil;
MTBuffer *resendRequestBuffer = [[MTBuffer alloc] init];
[resendRequestBuffer appendInt32:(int32_t)0x7d861a08];
[resendRequestBuffer appendInt32:481674261];
[resendRequestBuffer appendInt32:1];
[resendRequestBuffer appendInt64:_messageId];
NSData *resentMessagesRequestData = resendRequestBuffer.data;
MTOutgoingMessage *outgoingMessage = [[MTOutgoingMessage alloc] initWithData:resentMessagesRequestData metadata:@"resendMessages" shortMetadata:@"resendMessages"];
outgoingMessage.requiresConfirmation = false;
return [[MTMessageTransaction alloc] initWithMessagePayload:@[outgoingMessage] prepared:nil failed:nil completion:^(NSDictionary *messageInternalIdToTransactionId, NSDictionary *messageInternalIdToPreparedMessage, __unused NSDictionary *messageInternalIdToQuickAckId)
{
if ( messageInternalIdToTransactionId[outgoingMessage.internalId] != nil && messageInternalIdToPreparedMessage[outgoingMessage.internalId] != nil)
{
_currentRequestMessageId = ((MTPreparedMessage *)messageInternalIdToPreparedMessage[outgoingMessage.internalId]).messageId;
_currentRequestTransactionId = messageInternalIdToTransactionId[outgoingMessage.internalId];
if (MTLogEnabled()) {
MTLog(@"[MTResendMessageService#%p request %" PRId64 " for %" PRId64 "]", self, _currentRequestMessageId, _messageId);
}
}
}];
}
return nil;
}