//
//  channelContainer.h
//  oimcore
//
//  Created by offcnPlayer on 2022/4/13.
//

#import <Foundation/Foundation.h>


#import <UIKit/UIKit.h>
#import <oimcore/oim_types.h>


@protocol OIMCoreContainerDelegate <NSObject>
@required
-(void)OnOImCoreContainerMessageWithMessage:(int)channelID message:(const char *_Nonnull)message msgLength:(int)len;
-(void)OnOImCoreContainerEventWithCode:(int)channelID code:(OImEventCode)code errorCode:(int)nErrorCode context:(const char *_Nonnull)context;
@end

NS_ASSUME_NONNULL_BEGIN

@interface channelContainer : NSObject

@property(nonatomic, weak) id<OIMCoreContainerDelegate>   delegate;

-(instancetype )initWithDelegate:(id<OIMCoreContainerDelegate>)delegate;

/**
 *     create on channel
 *     @return   the channel ID
 */
-(int)createChannel;

/**
 * @param channelID  the  return value by createChannel function
 */
-(void)deleteChannel:(int)channelID;


/**
 *    connect to im server
 *
 *    @param     params                must contain server'ip and port in json format eg:
 *    {"server_ip":"192.168.1.1", "server_port":123, "account_id":"123", "app_id":"123", "device_type":"windows", "token":"213", "account_id":"123", "session_id":"1223", "connection_type":"kcp"}
 *   channelID      the  return value by createChannel function
 */
-(void)connectChannel:(int)channelID params:(NSString*_Nonnull)params;

/**
 * @param channelID    the  return value by createChannel function
 */
-(void)disconnectChannel:(int)channelID;

/**
 * 发送消息
 *
 *    @param    channelID    the  return value by createChannel function
 *    @param    message        message data, size less than 256 BYTES
 *    @param    type        message's type
 *
 */
-(void)SendUserMessage:(int)channelID message:(NSString*_Nonnull)message length:(int)len type:(OImMsgType)type;
@end

NS_ASSUME_NONNULL_END
