//
//  SLWebSocketManager.h
//  SLAiELTS
//
//  Created by Gusont on 2023/6/5.
//

#import <Foundation/Foundation.h>
#import <SocketRocket/SocketRocket.h>
#import "MessageModel.h"

NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, WebSocketStatus){
    WebSocketStatusDefault = 0, //初始状态，未连接
    WebSocketStatusConnect,     //已连接
    WebSocketStatusDisConnect,  //断开连接
};

@protocol WebSocketManagerDelegate<NSObject>

@optional

-(void)webSocketDidReceiveMessage:(NSString *)string;

-(void)webSocketDidReceiveChatMessage:(NSString *)string;

@end


@interface SLWebSocketManager : NSObject

@property(nonatomic, strong) SRWebSocket *webSocket;
@property(nonatomic, weak) id<WebSocketManagerDelegate> delegate;
@property(nonatomic, assign) BOOL isConnect; //是否连接
@property(nonatomic, assign) WebSocketStatus socketStatus;

+ (instancetype)SharedInstance;

-(void)connectServer;//建立长连接
-(void)reConnectServer;//重新连接
-(void)webSocketClose;//关闭连接
-(void)sendDataToServer:(NSString *)data; //向服务器发送数据


@end

NS_ASSUME_NONNULL_END
