/*
 *
 */

#import <Foundation/Foundation.h>

/**
 *
 *
 *  socket状态
 */
typedef NS_ENUM(NSInteger, RCSocketCloudPhoneStatus){
    RCSocketCloudPhoneStatusConnected,// 已连接
    RCSocketCloudPhoneStatusFailed,// 失败
    RCSocketCloudPhoneStatusClosedByServer,// 系统关闭
    RCSocketCloudPhoneStatusClosedByUser,// 用户关闭
    RCSocketCloudPhoneStatusReceived// 接收消息
};

/**
 *
 *
 *  消息类型
 */
typedef NS_ENUM(NSInteger,FLSocketCloudPhoneReceiveType){
    RCSocketCloudPhoneReceiveTypeForMessage,
    RCSocketCloudPhoneReceiveTypeForPong
};
/**
 *
 *
 *  连接成功回调
 */
typedef void(^RCSocketCloudPhoneDidConnectBlock)(void);
/**
 *
 *
 *  失败回调
 */
typedef void(^RCSocketCloudPhoneDidFailBlock)(NSError *error);
/**
 *
 *
 *  关闭回调
 */
typedef void(^RCSocketCloudPhoneDidCloseBlock)(NSInteger code,NSString *reason,BOOL wasClean);
/**
 *
 *
 *  消息接收回调
 */
typedef void(^RCSocketCloudPhoneDidReceiveBlock)(id message ,FLSocketCloudPhoneReceiveType type);

@interface RCSocketManagerForCloudPhone : NSObject
/**
 *
 *
 *  连接回调
 */
@property (nonatomic, copy) RCSocketCloudPhoneDidConnectBlock connect;
/**
 *
 *
 *  接收消息回调
 */
@property (nonatomic, copy) RCSocketCloudPhoneDidReceiveBlock receive;
/**
 *
 *
 *  失败回调
 */
@property (nonatomic, copy) RCSocketCloudPhoneDidFailBlock failure;
/**
 *
 *
 *  关闭回调
 */
@property (nonatomic, copy) RCSocketCloudPhoneDidCloseBlock close;
/**
 *
 *
 *  当前的socket状态
 */
@property (nonatomic, assign, readonly) RCSocketCloudPhoneStatus fl_socketStatus;
/**
 *  @author Clarence
 *
 *  重连次数,默认5次
 */
@property (nonatomic, assign) NSUInteger reconnectCount;

/**
 *
 *
 *  单例调用
 */
//+ (instancetype)shareManager;
/**
 *
 *
 *  开启socket
 *
 *  @param urlStr  服务器地址
 *  @param connect 连接成功回调
 *  @param receive 接收消息回调
 *  @param failure 失败回调
 */
- (void)fl_open:(NSString *)urlStr
        connect:(RCSocketCloudPhoneDidConnectBlock)connect
        receive:(RCSocketCloudPhoneDidReceiveBlock)receive
        failure:(RCSocketCloudPhoneDidFailBlock)failure;
/**
 *
 *
 *  关闭socket
 *
 *  @param close 关闭回调
 */
- (void)fl_close:(RCSocketCloudPhoneDidCloseBlock)close;
/**
 *
 *
 *  发送消息，NSString 或者 NSData
 *
 *  @param data Send a UTF8 String or Data.
 */
- (void)fl_send:(id)data;

@end
