summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLProtocolMessage.h
blob: 2fb741aed2f78a246dad222a8eef6a52d28101e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//  SDLSmartDeviceLinkProtocolMessage.h
//

#import <Foundation/Foundation.h>

@class SDLProtocolHeader;

NS_ASSUME_NONNULL_BEGIN

@interface SDLProtocolMessage : NSObject

/**
 *  The message's header.
 */
@property (strong, nonatomic) SDLProtocolHeader *header;

/**
 *  The message's payload.
 */
@property (nullable, strong, nonatomic) NSData *payload;

/**
 *  Returns the message's header and payload data.
 */
@property (strong, nonatomic, readonly) NSData *data;

/**
 *  Creates a SDLProtocolMessage object with the provided header and payload.
 *
 *  @param header   A SDLProtocolHeader object
 *  @param payload  The data to be passed in the message
 *  @return         A SDLProtocolMessage object
 */
+ (instancetype)messageWithHeader:(SDLProtocolHeader *)header andPayload:(nullable NSData *)payload; // Returns a V1 or V2 object

/**
 *  Returns the total size of the message.
 *
 *  @return The size of the message
 */
- (NSUInteger)size;

/**
 *  Prints a description of the SDLProtocolMessage object.
 *
 *  @return A string description of the SDLProtocolMessage
 */
- (NSString *)description;

/**
 * Used for RPC type messages to obtain the data in a dictionary.
 *
 *  @return The data in a dictionary
 */
- (nullable NSDictionary<NSString *, id> *)rpcDictionary;

@end

NS_ASSUME_NONNULL_END