open/demo_src/TCP_Client/MobileIMSDK4iDemo_tcp/MobileIMSDK4iDemo/IMClientManager.m

137 lines
4.0 KiB
Mathematica
Raw Normal View History

2025-01-18 15:55:12 +08:00
// ----------------------------------------------------------------------
// Copyright (C) 2021 (52im.net) & Jack Jiang.
// The MobileIMSDK_TCP (MobileIMSDK v6.x TCP) Project.
// All rights reserved.
//
// > Github: https://github.com/JackJiang2011/MobileIMSDK
// > : http://www.52im.net/forum-89-1.html
// > http://www.52im.net/
// > 215477170 (http://www.52im.net/topic-qqgroup.html)
// >
// > http://www.52im.net/thread-2792-1-1.html
//
// "即时通讯网(52im.net) - 即时通讯开发者社区!"
// ----------------------------------------------------------------------
#import "IMClientManager.h"
#import "ClientCoreSDK.h"
#import "ConfigEntity.h"
#import "TCPFrameCodec.h"
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - API
///////////////////////////////////////////////////////////////////////////////////////////
@interface IMClientManager ()
/* MobileIMSDK. true. */
@property (nonatomic) BOOL _init;
//
@property (strong, nonatomic) ChatBaseEventImpl *baseEventListener;
//
@property (strong, nonatomic) ChatMessageEventImpl *transDataListener;
//
@property (strong, nonatomic) MessageQoSEventImpl *messageQoSListener;
@end
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
///////////////////////////////////////////////////////////////////////////////////////////
@implementation IMClientManager
//
static IMClientManager *instance = nil;
+ (IMClientManager *)sharedInstance
{
if (instance == nil)
{
instance = [[super allocWithZone:NULL] init];
}
return instance;
}
/*
* init
*
* @return
* @see [NSObject init:]
*/
- (id)init
{
if (![super init])
return nil;
[self initMobileIMSDK];
return self;
}
- (void)initMobileIMSDK
{
if(!self._init)
{
// AppKey
[ConfigEntity registerWithAppKey:@"5418023dfd98c579b6001741"];
// ip
// [ConfigEntity setServerIp:@"rbcore.52im.net"];
// [ConfigEntity setServerPort:7901];
// 使port使7801
// [ConfigEntity setLocalSendAndListeningPort:-1];
// MobileIMSDKIM
[ConfigEntity setSenseMode:SenseMode5S];
// TCP 6 * 1024
// [TCPFrameCodec setTCP_FRAME_MAX_BODY_LENGTH:60 * 1024];
// SSL/TLSSSLSSL
// [ClientCoreSDK setSSL:YES];
// DEBUG
[ClientCoreSDK setENABLED_DEBUG:YES];
//
self.baseEventListener = [[ChatBaseEventImpl alloc] init];
self.transDataListener = [[ChatMessageEventImpl alloc] init];
self.messageQoSListener = [[MessageQoSEventImpl alloc] init];
[ClientCoreSDK sharedInstance].chatBaseEvent = self.baseEventListener;
[ClientCoreSDK sharedInstance].chatMessageEvent = self.transDataListener;
[ClientCoreSDK sharedInstance].messageQoSEvent = self.messageQoSListener;
self._init = YES;
}
}
- (void)releaseMobileIMSDK
{
[[ClientCoreSDK sharedInstance] releaseCore];
[self resetInitFlag];
}
- (void)resetInitFlag
{
self._init = NO;
}
- (ChatMessageEventImpl *) getTransDataListener
{
return self.transDataListener;
}
- (ChatBaseEventImpl *) getBaseEventListener
{
return self.baseEventListener;
}
- (MessageQoSEventImpl *) getMessageQoSListener
{
return self.messageQoSListener;
}
@end