summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLSecondaryTransportManager.h
blob: 0af612d7e63e06384adbe809b97b121250e45552 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
//  SDLSecondaryTransportManager.h
//  SmartDeviceLink-iOS
//
//  Created by Sho Amano on 2018/02/28.
//  Copyright © 2018 Xevo Inc. All rights reserved.
//

#import "SDLProtocolListener.h"
#import "SDLStreamingProtocolDelegate.h"

@class SDLControlFramePayloadRPCStartServiceAck;
@class SDLControlFramePayloadTransportEventUpdate;
@class SDLProtocol;
@class SDLStateMachine;

NS_ASSUME_NONNULL_BEGIN

typedef NSString SDLSecondaryTransportState;
extern SDLSecondaryTransportState *const SDLSecondaryTransportStateStopped;
extern SDLSecondaryTransportState *const SDLSecondaryTransportStateStarted;
extern SDLSecondaryTransportState *const SDLSecondaryTransportStateConfigured;
extern SDLSecondaryTransportState *const SDLSecondaryTransportStateConnecting;
extern SDLSecondaryTransportState *const SDLSecondaryTransportStateRegistered;
extern SDLSecondaryTransportState *const SDLSecondaryTransportStateReconnecting;

/**
 A class to control and manage secondary transport feature.
 
 Secondary transport manager does most of the things required for the feature. It listens
 on the primary transport and receives necessary information through Version Negotiation
 and TransportEventUpdate control frame. It initiates secondary transport's connection
 and sets up SDLProtocol that runs on the transport. Then it starts streaming media
 manager with appropriate SDLProtocol instance. When the secondary transport is
 disconnected, this manager retries connection with a regular interval.
 */
@interface SDLSecondaryTransportManager : NSObject <SDLProtocolListener>

/** state of this manager */
@property (strong, nonatomic, readonly) SDLStateMachine *stateMachine;

/**
 Create a new secondary transport manager.

 @param streamingProtocolDelegate a delegate to handle updates on protocol instances
 @param queue a serial dispatch queue that the internal state machine runs on
 @return A new secondary transport manager
 */
- (instancetype)initWithStreamingProtocolDelegate:(id<SDLStreamingProtocolDelegate>)streamingProtocolDelegate
                                      serialQueue:(dispatch_queue_t)queue;

/**
 *  Start the manager.

 @param primaryProtocol protocol that runs on the main (primary) transport
 */
- (void)startWithPrimaryProtocol:(SDLProtocol *)primaryProtocol;

/**
 *  Stop the manager.
 */
- (void)stop;

/**
 * Call this method when Start Service ACK control frame is received on primary transport.

 @param payload payload of Start Service ACK frame received on the primary transport
 */
- (void)onStartServiceAckReceived:(SDLControlFramePayloadRPCStartServiceAck *)payload;

/**
 * Call this method when Transport Event Update control frame is received on primary transport.

 @param payload payload of Transport Event Update frame received on the primary transport
 */
- (void)onTransportEventUpdateReceived:(SDLControlFramePayloadTransportEventUpdate *)payload;

@end

NS_ASSUME_NONNULL_END