123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /*
- *
- */
- #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
|