Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2017 Google
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import <Foundation/Foundation.h>
18
 
19
@class FIRMessagingPersistentSyncMessage;
20
 
21
/**
22
 * This manages the RMQ persistent store.
23
 *
24
 * The store is used to store all the S2D id's that were received by the client and were ACK'ed
25
 * by us but the server hasn't confirmed the ACK. We don't delete these id's until the server
26
 * ACK's us that they have received them.
27
 *
28
 * We also store the upstream messages(d2s) that were sent by the client.
29
 *
30
 * Also store the lastRMQId that was sent by us so that for a new connection being setup we don't
31
 * duplicate RMQ Id's for the new messages.
32
 */
33
@interface FIRMessagingRmqManager : NSObject
34
// designated initializer
35
- (instancetype)initWithDatabaseName:(NSString *)databaseName;
36
 
37
- (void)loadRmqId;
38
 
39
/**
40
 *  Save Server to device message with the given RMQ-ID.
41
 *
42
 *  @param rmqID The rmqID of the s2d message to save.
43
 *
44
 */
45
- (void)saveS2dMessageWithRmqId:(NSString *)rmqID;
46
 
47
#pragma mark - Sync Messages
48
 
49
/**
50
 *  Get persisted sync message with rmqID.
51
 *
52
 *  @param rmqID The rmqID of the persisted sync message.
53
 *
54
 *  @return A valid persistent sync message with the given rmqID if found in the RMQ else nil.
55
 */
56
- (FIRMessagingPersistentSyncMessage *)querySyncMessageWithRmqID:(NSString *)rmqID;
57
 
58
/**
59
 *  Delete the expired sync messages from persisten store. Also deletes messages that have been
60
 *  delivered both via APNS and MCS.
61
 */
62
- (void)deleteExpiredOrFinishedSyncMessages;
63
 
64
/**
65
 *  Save sync message received by the device.
66
 *
67
 *  @param rmqID          The rmqID of the message received.
68
 *  @param expirationTime The expiration time of the sync message received.
69
 *
70
 */
71
- (void)saveSyncMessageWithRmqID:(NSString *)rmqID expirationTime:(int64_t)expirationTime;
72
 
73
/**
74
 *  Update sync message received via APNS.
75
 *
76
 *  @param rmqID The rmqID of the received message.
77
 *
78
 */
79
- (void)updateSyncMessageViaAPNSWithRmqID:(NSString *)rmqID;
80
 
81
/**
82
 * Returns path for database with specified name.
83
 * @param databaseName The database name without extension: "<databaseName>.sqlite".
84
 * @return Path to the database with the specified name.
85
 */
86
+ (NSString *)pathForDatabaseWithName:(NSString *)databaseName;
87
 
88
@end