//
//  RYSharedAccessory.h
//  SDK
//
//  Created by ldc on 2024/1/8.
//

#import <Foundation/Foundation.h>
#import <RYCommunication/RYResolver.h>
#import <RYCommunication/RYBleAccessory.h>
#import <ExternalAccessory/ExternalAccessory.h>
#import <RYCommunication/RYSocketAccessory.h>
#import <RYCommunication/RYExternalAccessory.h>
#import <RYCommunication/RYSessionManager.h>
#import <RYCommunication/RYBaseAccessory.h>

NS_ASSUME_NONNULL_BEGIN

@protocol RYMessageReceiver;

@interface RYSharedAccessory : RYBaseAccessory

@property (nonatomic, assign, readonly) BOOL isBLE;

@property (nonatomic, assign, readonly) BOOL isExternAccessory;

@property (nonatomic, assign, readonly) BOOL isSocket;

@property (nonatomic, strong) id<RYAccessory> accessory;

/**
 *  \~chinese
 *
 *  Session 超时时间
 *
 *  \~english
 *
 *  Session timeout
 *
 */
@property (nonatomic, assign) NSTimeInterval timeout;

/**
 *  \~chinese
 *
 *  创建socket设备对象
 *
 *  @param ip ip
 *  @param port port
 *
 *  \~english
 *
 *  Create socket accessory object
 *
 *  @param ip ip
 *  @param port port
 *
 */
- (instancetype)initWith:(NSString *)ip port:(NSInteger)port;

/**
 *  \~chinese
 *
 *  创建MFI设备对象
 *  @param accessory 系统外设对象
 *  @param protocolString 设备协议
 *
 *  \~english
 *
 *  Create MFI RYExternalAccessory object
 *
 *  @param accessory EAAccessory
 *  @param protocolString MFI protocol
 *
 */
- (instancetype)initWithAccessory:(EAAccessory *)accessory forProtocol:(NSString *)protocolString;

- (instancetype)initWithBleAccessory:(RYBleAccessory *)accessory;

- (instancetype)initWith:(RYBaseAccessory *)accessory;

- (void)addMessageReceiver:(id<RYMessageReceiver>)receiver;

- (void)removeMessageReceiver:(id<RYMessageReceiver>)receiver;

- (void)removeAllMessageReceivers;

@end

NS_ASSUME_NONNULL_END
