Commit 955d7797 by zhangyunjie

添加接口

parent bd6cea63
......@@ -202,10 +202,23 @@
A96621F524EA84160024EB54 /* libxml2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A96621F424EA83D70024EB54 /* libxml2.tbd */; };
A96621F624EA84230024EB54 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A96621F324EA83C90024EB54 /* libsqlite3.tbd */; };
A96621F724EA842E0024EB54 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A96621F224EA83BB0024EB54 /* libresolv.tbd */; };
A96621F924EA860E0024EB54 /* oimcore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A96621F824EA860E0024EB54 /* oimcore.framework */; };
A966274D24EBA56C0024EB54 /* OffcnIMSDKiOS.m in Sources */ = {isa = PBXBuildFile; fileRef = A966274C24EBA56C0024EB54 /* OffcnIMSDKiOS.m */; };
B94FCB1053F8932068A11CC9 /* libPods-OffcnIMSDKiOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49CE5E230A14D9B821170F61 /* libPods-OffcnIMSDKiOS.a */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
A966275024EBD28A0024EB54 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
3F07C2EC97AF605DC6BD528E /* Pods-OffcnIMSDKiOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OffcnIMSDKiOS.debug.xcconfig"; path = "Target Support Files/Pods-OffcnIMSDKiOS/Pods-OffcnIMSDKiOS.debug.xcconfig"; sourceTree = "<group>"; };
49CE5E230A14D9B821170F61 /* libPods-OffcnIMSDKiOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OffcnIMSDKiOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -615,7 +628,8 @@
A96621F224EA83BB0024EB54 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
A96621F324EA83C90024EB54 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
A96621F424EA83D70024EB54 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; };
A96621F824EA860E0024EB54 /* oimcore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = oimcore.framework; sourceTree = "<group>"; };
A966274B24EBA56C0024EB54 /* OffcnIMSDKiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffcnIMSDKiOS.h; sourceTree = "<group>"; };
A966274C24EBA56C0024EB54 /* OffcnIMSDKiOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OffcnIMSDKiOS.m; sourceTree = "<group>"; };
D7DCDED1DEE7F99F223D5C73 /* Pods-OffcnIMSDKiOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OffcnIMSDKiOS.release.xcconfig"; path = "Target Support Files/Pods-OffcnIMSDKiOS/Pods-OffcnIMSDKiOS.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -628,7 +642,6 @@
A96621F624EA84230024EB54 /* libsqlite3.tbd in Frameworks */,
A96621F524EA84160024EB54 /* libxml2.tbd in Frameworks */,
A96621EF24EA83A80024EB54 /* SystemConfiguration.framework in Frameworks */,
A96621F924EA860E0024EB54 /* oimcore.framework in Frameworks */,
A96621F124EA83B10024EB54 /* CoreTelephony.framework in Frameworks */,
B94FCB1053F8932068A11CC9 /* libPods-OffcnIMSDKiOS.a in Frameworks */,
);
......@@ -667,7 +680,7 @@
A9661B4224EA64EE0024EB54 /* OffcnIMSDKiOS */ = {
isa = PBXGroup;
children = (
A96621F824EA860E0024EB54 /* oimcore.framework */,
A966274724EBA36A0024EB54 /* ExposedInterface-(外放接口) */,
A9661FC824EA7AD10024EB54 /* Common-(宏) */,
A9661F8124EA7AD10024EB54 /* Tools-(工具) */,
A9661B5C24EA72900024EB54 /* AppDelegate.h */,
......@@ -856,10 +869,10 @@
A9661FC324EA7AD10024EB54 /* GeneralTool */ = {
isa = PBXGroup;
children = (
A9661FC424EA7AD10024EB54 /* SDGeneralTool.m */,
A9661FC524EA7AD10024EB54 /* OffcnToast.m */,
A9661FC624EA7AD10024EB54 /* SDGeneralTool.h */,
A9661FC424EA7AD10024EB54 /* SDGeneralTool.m */,
A9661FC724EA7AD10024EB54 /* OffcnToast.h */,
A9661FC524EA7AD10024EB54 /* OffcnToast.m */,
);
path = GeneralTool;
sourceTree = "<group>";
......@@ -1408,6 +1421,15 @@
path = ZYJAFNetworking;
sourceTree = "<group>";
};
A966274724EBA36A0024EB54 /* ExposedInterface-(外放接口) */ = {
isa = PBXGroup;
children = (
A966274B24EBA56C0024EB54 /* OffcnIMSDKiOS.h */,
A966274C24EBA56C0024EB54 /* OffcnIMSDKiOS.m */,
);
path = "ExposedInterface-(外放接口)";
sourceTree = "<group>";
};
CC1958D307ED3EA5F9EA7118 /* Frameworks */ = {
isa = PBXGroup;
children = (
......@@ -1432,6 +1454,7 @@
A9661B3C24EA64ED0024EB54 /* Sources */,
A9661B3D24EA64ED0024EB54 /* Frameworks */,
A9661B3E24EA64ED0024EB54 /* Resources */,
A966275024EBD28A0024EB54 /* Embed Frameworks */,
);
buildRules = (
);
......@@ -1552,6 +1575,7 @@
A9661FDF24EA7AD10024EB54 /* NSAttributedString+SDSize.m in Sources */,
A96621C424EA80A60024EB54 /* ZYJOSSIPv6PrefixResolver.m in Sources */,
A96621EB24EA80A60024EB54 /* ZYJAFURLSessionManager.m in Sources */,
A966274D24EBA56C0024EB54 /* OffcnIMSDKiOS.m in Sources */,
A96621AF24EA80A60024EB54 /* ZYJOSSResult.m in Sources */,
A966219124EA80A60024EB54 /* ZYJMJRefreshAutoGifFooter.m in Sources */,
A966215C24EA80A60024EB54 /* NSObject+ZYJMJClass.m in Sources */,
......@@ -1847,6 +1871,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = LA78A3696S;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/OffcnIMSDKiOS",
......@@ -1858,9 +1883,13 @@
"@executable_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.eoffcn.classonline;
OTHER_LDFLAGS = (
"-ObjC",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = com.eoffcn.questions;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ClassonlineDev;
PROVISIONING_PROFILE_SPECIFIER = WXQuestionDev;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
......@@ -1873,6 +1902,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = LA78A3696S;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/OffcnIMSDKiOS",
......@@ -1883,9 +1913,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.eoffcn.classonline;
OTHER_LDFLAGS = (
"-ObjC",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = com.eoffcn.questions;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ClassonlineDev;
PROVISIONING_PROFILE_SPECIFIER = WXQuestionDev;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
......
......@@ -52,7 +52,7 @@
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
......
//
// AppDelegate.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
// AppDelegate.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......@@ -8,6 +8,7 @@
#import "AppDelegate.h"
#import "ViewController.h"
#import "OffcnIMSDKiOS.h"
@interface AppDelegate ()
......@@ -28,12 +29,14 @@
//中公直播使用测试环境设置为YES,正式环境设置为NO或者去掉这个配置
// NSNumber *changeEnvironment = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnLiveSDK_changeEnvironment];
// NSLog(@"changeEnvironment---%@",changeEnvironment);
// [OffcnLiveSDK defaultService].isTest = [changeEnvironment boolValue];
NSNumber *changeEnvironment = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_changeEnvironment];
NSLog(@"changeEnvironment---%@",changeEnvironment);
[OffcnIMSDKiOS defaultService].isTest = [changeEnvironment boolValue];
[OffcnIMSDKiOS defaultService].isTest = YES;
//获取网络状态和内部初始化处理
// [[OffcnLiveSDK defaultService] startNotifierUseRealReachability];
[[OffcnIMSDKiOS defaultService] startNotifierUseRealReachability];
return YES;
}
......
//
//
//
// ConfigrationNetwork.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......@@ -10,41 +10,22 @@
#define ConfigrationNetwork_h
//默认大班课开发模式接口
#define DEV_BASEURL @"https://live.offcncloud.com/"
#define DEV_BASEURL @"http://im.offcncloud.com:8080"
#define DEV_IMAGEBASEURL @""
#define DEV_h5live @"https://h5live.offcncloud.com/"
#define DEV_call_server_topic @"rtc.offcncloud.com"
#define DEV_h5live @""
#define DEV_call_server_topic @""
//默认大班课测试模式接口
#define TEST_BASEURL @"http://test-live.offcncloud.com/"
#define TEST_BASEURL @"http://test-im.offcncloud.com:8080"
#define TEST_IMAGEBASEURL @""
#define TEST_h5live @"http://test-h5live.offcncloud.com/"
#define TEST_call_server_topic @"test-rtc.offcncloud.com"
#define TEST_h5live @""
#define TEST_call_server_topic @""
//默认大班课生产模式接口
#define PRO_BASEURL @"https://live.offcncloud.com/"
#define PRO_BASEURL @"http://im.offcncloud.com:8080"
#define PRO_IMAGEBASEURL @""
#define PRO_h5live @"https://h5live.offcncloud.com/"
#define PRO_call_server_topic @"rtc.offcncloud.com"
//小班课开发模式接口
#define DEV_BASEURL_SMALLCLASS @"https://api.live.offcncloud.com/"
#define DEV_IMAGEBASEURL_SMALLCLASS @""
#define DEV_h5live_SMALLCLASS @"https://api.h5live.offcncloud.com/"
#define DEV_call_server_topic_SMALLCLASS @"rtc.smallroom.offcncloud.com"
//小班课测试模式接口
#define TEST_BASEURL_SMALLCLASS @"http://test-api.live.offcncloud.com/"
#define TEST_IMAGEBASEURL_SMALLCLASS @""
#define TEST_h5live_SMALLCLASS @"http://test-api.h5live.offcncloud.com/"
#define TEST_call_server_topic_SMALLCLASS @"test-rtc.smallroom.offcncloud.com"
//小班课生产模式接口
#define PRO_BASEURL_SMALLCLASS @"https://api.live.offcncloud.com/"
#define PRO_IMAGEBASEURL_SMALLCLASS @""
#define PRO_h5live_SMALLCLASS @"https://api.h5live.offcncloud.com/"
#define PRO_call_server_topic_SMALLCLASS @"rtc.smallroom.offcncloud.com"
#define PRO_h5live @""
#define PRO_call_server_topic @""
//切换连麦call_server_topic
......@@ -57,17 +38,21 @@
#define BASE_H5_URL [OffcnBaseNetworking get_h5live]
#define BASE_URL [NSString stringWithFormat:@"%@api/v1/",BASE_DOMAIN_URL]
#define BASE_USER_URL [NSString stringWithFormat:@"%@api/user/",BASE_DOMAIN_URL]
#define BASE_URL [NSString stringWithFormat:@"%@/v1/",BASE_DOMAIN_URL]
#define BASE_USER_URL [NSString stringWithFormat:@"%@/user/",BASE_DOMAIN_URL]
#define HTTPS_IMAGEBASEURL @""
#pragma mark - 二级API
//客户端登陆
//#define LoginURL [NSString stringWithFormat:@"%@users",BASE_URL]
//回放拉流
//#define PlaybackPullURL [NSString stringWithFormat:@"%@on_demand",BASE_USER_URL]
//发送消息
#define sendMsgURL [NSString stringWithFormat:@"%@sendMsg",BASE_URL]
//用户信息标记已读
#define markMsgReadURL [NSString stringWithFormat:@"%@markMsgRead",BASE_URL]
//获取会话未读消息列表
#define getSessionUnreadMsgURL [NSString stringWithFormat:@"%@getSessionUnreadMsg",BASE_URL]
//获取用户最近会话记录
#define getRecentSessionsURL [NSString stringWithFormat:@"%@getRecentSessions",BASE_URL]
//获取会话历史消息列表
#define getSessionHistoryMsgURL [NSString stringWithFormat:@"%@getSessionHistoryMsg",BASE_URL]
#endif /* ConfigrationNetwork_h */
//
// SDEnum.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/13.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
......@@ -20,7 +20,8 @@ fprintf(stderr, "-------\n"); \
#define NSLog(FORMAT, ...)
#endif
#define KCustomerAPPKEY @""
#define KCustomerAPPKEY @"offcn_live"
#define KCustomerSecre @"offcn_im"
#pragma mark - 尺寸所有宏
......@@ -54,9 +55,9 @@ fprintf(stderr, "-------\n"); \
#define KSetFont(size) [UIFont systemFontOfSize:size]
#define KImageNamed(name) [UIImage imageNamed:[NSString stringWithFormat:@"OffcnLiveSDK.bundle/%@",name]]
#define KImageNamed(name) [UIImage imageNamed:[NSString stringWithFormat:@"OffcnIMSDKiOS.bundle/%@",name]]
#define KEmojiImageNamed(name) [UIImage imageNamed:[NSString stringWithFormat:@"OffcnLiveSDK.bundle/emoji/%@",name]]
#define KEmojiImageNamed(name) [UIImage imageNamed:[NSString stringWithFormat:@"OffcnIMSDKiOS.bundle/emoji/%@",name]]
#define KWeakSelf __weak typeof(self) weakSelf = self;
......
//
//
//
// SDKeyBoard.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/9/6.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
// OffcnIMSDKiOS.h
// OffcnIMSDKiOS
//
// Created by vockey on 2018/10/16.
// Copyright © 2018年 中公教育. All rights reserved.
//
#import <UIKit/UIKit.h>
static const NSString *OffcnIMSDKiOSVersion = @"1.0.0.0";
typedef NS_ENUM(NSUInteger, OffcnSDKReachabilityStatus) {
OffcnSDKReachabilityStatusNotReachable = 0,
OffcnSDKReachabilityStatusViaWWAN,
OffcnSDKReachabilityStatusViaWiFi,
};
typedef NS_ENUM(NSUInteger, OffcnSDKMsgType) {
OffcnSDKMsgTypeText = 1, //文本消息
OffcnSDKMsgTypePicture, //图片消息
OffcnSDKMsgTypeAudio, //音频消息
OffcnSDKMsgTypeVideo, //视频消息
OffcnSDKMsgTypeFile, //文件消息
};
typedef NS_ENUM(NSUInteger, OffcnSDKMsgScope) {
OffcnSDKMsgScopeSingleChat = 1, //单聊消息
OffcnSDKMsgScopeGroupChat, //群聊消息
};
typedef NS_ENUM(NSUInteger, OffcnSDKType) {
OffcnSDKTypeIM = 1, //IM 消息
};
//网络监听回调
typedef void(^OffcnSDKReachabilityStatusCallBack)(OffcnSDKReachabilityStatus status);
@interface OffcnIMSDKiOS : NSObject
//返回单例对象
+ (OffcnIMSDKiOS *)defaultService;
//是否选用测试环境
@property (nonatomic, assign) BOOL isTest;
@property (nonatomic, assign) OffcnSDKReachabilityStatus OffcnReachabilityStatus;
@property (nonatomic, copy) OffcnSDKReachabilityStatusCallBack reachabilityStatusCallBack;
//监听网络状态
-(void)startNotifierUseRealReachability;
@end
//
//
// OffcnIMSDKiOS.m
// OffcnIMSDKiOS
//
// Created by vockey on 2018/10/16.
// Copyright © 2018年 中公教育. All rights reserved.
//
#import "OffcnIMSDKiOS.h"
#import "OffcnBaseNetworking.h"
#import "ZYJRealReachability.h"
#import "SDGeneralDefine.h"
#import "OffcnNetworkExecutor.h"
@interface OffcnIMSDKiOS ()
@end
@implementation OffcnIMSDKiOS
static OffcnIMSDKiOS *liveTelecastSDK;
+ (OffcnIMSDKiOS *)defaultService{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
liveTelecastSDK = [[OffcnIMSDKiOS alloc] init];
});
return liveTelecastSDK;
}
-(void)setIsTest:(BOOL)isTest{
if (isTest) {
[[OffcnBaseNetworking sharedInstance] setServiceType:2];
}else{
[[OffcnBaseNetworking sharedInstance] setServiceType:3];
}
_isTest = isTest;
}
#pragma mark - 使用RealReachability监听网络状态
-(void)startNotifierUseRealReachability{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChanged:) name:ZYJkRealReachabilityChangedNotification object:nil];
GLobalRealReachability.hostForPing = @"api.live.offcncloud.com";
GLobalRealReachability.pingTimeout = 10;
[GLobalRealReachability startNotifier];
ReachabilityStatus status = [GLobalRealReachability currentReachabilityStatus];
[self realNetworkingStatus:status];
}
- (void)networkChanged:(NSNotification *)notification
{
ZYJRealReachability *reachability= (ZYJRealReachability *)notification.object;
ReachabilityStatus status= [reachability currentReachabilityStatus];
[self realNetworkingStatus:status];
}
-(void)realNetworkingStatus:(ReachabilityStatus)status{
KWeakSelf
switch (status){
case RealStatusUnknown:
case RealStatusNotReachable:
{
[OffcnNetworkExecutor requesImgJsonWithUrlStr:@"https://api.live.offcncloud.com" Finished:^(BOOL success, id response, NSString *message) {
if (success) {
weakSelf.OffcnReachabilityStatus = OffcnSDKReachabilityStatusViaWiFi;
if (weakSelf.reachabilityStatusCallBack) {
weakSelf.reachabilityStatusCallBack(OffcnSDKReachabilityStatusViaWiFi);
}
}else{
weakSelf.OffcnReachabilityStatus = OffcnSDKReachabilityStatusNotReachable;
if (weakSelf.reachabilityStatusCallBack) {
weakSelf.reachabilityStatusCallBack(OffcnSDKReachabilityStatusNotReachable);
}
}
}];
break;
}
case RealStatusViaWWAN:
{
self.OffcnReachabilityStatus = OffcnSDKReachabilityStatusViaWWAN;
if (self.reachabilityStatusCallBack) {
self.reachabilityStatusCallBack(OffcnSDKReachabilityStatusViaWWAN);
}
break;
}
case RealStatusViaWiFi:
{
self.OffcnReachabilityStatus = OffcnSDKReachabilityStatusViaWiFi;
if (self.reachabilityStatusCallBack) {
self.reachabilityStatusCallBack(OffcnSDKReachabilityStatusViaWiFi);
}
break;
}
default:
break;
}
}
-(void)dealloc{
}
@end
......@@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
......
//
//
//
// NSAttributedString+SDSize.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/23.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
// NSAttributedString+SDSize.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/23.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// NSMutableAttributedString+SDSize.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/23.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// NSMutableAttributedString+SDSize.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/23.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// SDButton.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/31.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// SDButton.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/31.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// SDLabel.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/8.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
// SDLabel.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/8/8.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// OffcnToast.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2019/4/9.
// Copyright © 2019年 中公教育. All rights reserved.
......
//
//
//
// OffcnToast.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2019/4/9.
// Copyright © 2019年 中公教育. All rights reserved.
......
//
//
......@@ -35,6 +35,10 @@
+(NSString*)getAllCurrentTimes;
//获取当前时间戳(以毫秒为单位)
+(NSString *)getNowTimeTimestampMillisecond;
//获取当前时间戳(以秒为单位)
+(NSString *)getNowSSTimeTimestamp;
//获取当前时间戳(以毫秒为单位)
+(NSString *)getNowSSSTimeTimestamp;
+(NSString *)getHHTimeWithSeconds:(NSTimeInterval)s;
......@@ -67,4 +71,7 @@
+(NSString *)getGMTTimestamp;
//隐藏手机号
+(NSString *)hidNameWithStr:(NSString *)str;
//普通字符串转换为十六进制的
+(NSString *)hexStringFromString:(NSString *)string;
@end
//
//
......@@ -256,7 +256,7 @@
[format setDateFormat:@"yyyy-MM-dd"];
return [format stringFromDate:date];
}
//获取当前时间(以毫秒为单位)
//获取当前时间(以毫秒为单位)
+(NSString *)getNowTimeTimestampMillisecond{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
......@@ -303,6 +303,33 @@
NSInteger timeSp = [[NSNumber numberWithDouble:[date timeIntervalSince1970]] integerValue];
return timeSp;
}
//获取当前时间戳(以秒为单位)
+(NSString *)getNowSSTimeTimestamp{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; //
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setTimeZone:timeZone];
NSDate *datenow = [NSDate date];
NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[datenow timeIntervalSince1970]];
return timeSp;
}
//获取当前时间戳(以毫秒为单位)
+(NSString *)getNowSSSTimeTimestamp{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss SSS"]; //
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[formatter setTimeZone:timeZone];
NSDate *datenow = [NSDate date];
NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)([datenow timeIntervalSince1970]*1000)];
return timeSp;
}
#pragma mark 获取系统开机时间到1970时间差值
+(double)getLaunchSystemTime{
NSTimeInterval sysTime = [NSProcessInfo processInfo].systemUptime;
......@@ -364,4 +391,21 @@
return str;
}
//普通字符串转换为十六进制的
+(NSString *)hexStringFromString:(NSString *)string{
NSData *myD = [string dataUsingEncoding:NSUTF8StringEncoding];
Byte *bytes = (Byte *)[myD bytes];
//下面是Byte 转换为16进制。
NSString *hexStr = @"";
for(int i=0;i<[myD length];i++){
NSString *newHexStr = [NSString stringWithFormat:@"%x",bytes[i]&0xff];///16进制数
if([newHexStr length]==1){
hexStr = [NSString stringWithFormat:@"%@0%@",hexStr,newHexStr];
}else{
hexStr = [NSString stringWithFormat:@"%@%@",hexStr,newHexStr];
}
}
return hexStr;
}
@end
//
//
//
// OffcnBaseNetworking.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......
//
//
//
// OffcnBaseNetworking.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......@@ -13,6 +13,8 @@
#import "SDGeneralTool.h"
#import "SDConfigrationNetwork.h"
#import "ZYJMJExtension.h"
#import "SDGeneralDefine.h"
#import "ZYJOSSUtil.h"
static OffcnBaseNetworking *baseNetWorkApi;
......@@ -31,37 +33,37 @@ static OffcnBaseNetworking *baseNetWorkApi;
+(NSString *)get_BASEURL{
NSInteger type = [OffcnBaseNetworking sharedInstance].serviceType;
if (type == 1) {
return DEV_BASEURL_SMALLCLASS;
return DEV_BASEURL;
}else if (type == 2) {
return TEST_BASEURL_SMALLCLASS;
return TEST_BASEURL;
}else if (type == 3) {
return PRO_BASEURL_SMALLCLASS;
return PRO_BASEURL;
}
return PRO_BASEURL_SMALLCLASS;
return PRO_BASEURL;
}
//h5服务器
+(NSString *)get_h5live{
NSInteger type = [OffcnBaseNetworking sharedInstance].serviceType;
if (type == 1) {
return DEV_h5live_SMALLCLASS;
return DEV_h5live;
}else if (type == 2) {
return TEST_h5live_SMALLCLASS;
return TEST_h5live;
}else if (type == 3) {
return PRO_h5live_SMALLCLASS;
return PRO_h5live;
}
return PRO_h5live_SMALLCLASS;
return PRO_h5live;
}
//call_server_topic服务器
+(NSString *)get_call_server_topic{
NSInteger type = [OffcnBaseNetworking sharedInstance].serviceType;
if (type == 1) {
return DEV_call_server_topic_SMALLCLASS;
return DEV_call_server_topic;
}else if (type == 2) {
return TEST_call_server_topic_SMALLCLASS;
return TEST_call_server_topic;
}else if (type == 3) {
return PRO_call_server_topic_SMALLCLASS;
return PRO_call_server_topic;
}
return PRO_call_server_topic_SMALLCLASS;
return PRO_call_server_topic;
}
//图片服务器
+(NSString *)get_ImageBaseUrl{
......@@ -202,22 +204,35 @@ static OffcnBaseNetworking *baseNetWorkApi;
}
+ (void)setHttpCommonHeader:(ZYJAFHTTPSessionManager *)manager{
// [manager.requestSerializer setValue:XiaoHongMaoAPPKEY forHTTPHeaderField:@"phoneKey"];
[manager.requestSerializer setValue:@"ZgLiveStudent" forHTTPHeaderField:@"zgl-clienttype"];
[manager.requestSerializer setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] forHTTPHeaderField:@"zgl-clientversion"];
[manager.requestSerializer setValue:@"iOS" forHTTPHeaderField:@"zgl-systemtype"];
NSString *systemString = [NSString stringWithFormat:@"%@",[UIDevice currentDevice].systemVersion];
[manager.requestSerializer setValue:systemString forHTTPHeaderField:@"zgl-systemversion"];
[manager.requestSerializer setValue:[UIDevice currentDevice].identifierForVendor.UUIDString forHTTPHeaderField:@"zgl-phonekey"];
[manager.requestSerializer setValue:[SDGeneralTool deviceVersion] forHTTPHeaderField:@"zgl-phonetype"];
NSString *screenString = [NSString stringWithFormat:@"%.0fx%.0f",[UIScreen mainScreen].bounds.size.width * [UIScreen mainScreen].scale,[UIScreen mainScreen].bounds.size.height * [UIScreen mainScreen].scale];
[manager.requestSerializer setValue:screenString forHTTPHeaderField:@"zgl-resolution"];
[manager.requestSerializer setValue:KCustomerAPPKEY forHTTPHeaderField:@"appkey"];
//随机数(最大长度128个字符)
NSString *nonceStr = [SDGeneralTool getNowSSSTimeTimestamp];
[manager.requestSerializer setValue:nonceStr forHTTPHeaderField:@"nonce"];
//当前UTC时间戳,从1970年1月1日0点0 分0 秒开始到现在的秒数(String)
NSString *curtimeStr = [SDGeneralTool getNowSSTimeTimestamp];
[manager.requestSerializer setValue:curtimeStr forHTTPHeaderField:@"curtime"];
//SHA1(AppSecret + Nonce + CurTime),三个参数拼接的字符串,进行SHA1哈希计算,转化成16进制字符(String,小写)
NSString *margeStr = [NSString stringWithFormat:@"%@%@%@",KCustomerSecre,nonceStr,curtimeStr];
NSString *checksumStr = [ZYJOSSUtil sha1WithString:margeStr];
checksumStr = [[SDGeneralTool hexStringFromString:checksumStr] lowercaseString];
[manager.requestSerializer setValue:checksumStr forHTTPHeaderField:@"checksum"];
// [manager.requestSerializer setValue:@"ZgLiveStudent" forHTTPHeaderField:@"zgl-clienttype"];
// [manager.requestSerializer setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] forHTTPHeaderField:@"zgl-clientversion"];
// [manager.requestSerializer setValue:@"iOS" forHTTPHeaderField:@"zgl-systemtype"];
// NSString *systemString = [NSString stringWithFormat:@"%@",[UIDevice currentDevice].systemVersion];
// [manager.requestSerializer setValue:systemString forHTTPHeaderField:@"zgl-systemversion"];
// [manager.requestSerializer setValue:[UIDevice currentDevice].identifierForVendor.UUIDString forHTTPHeaderField:@"zgl-phonekey"];
// [manager.requestSerializer setValue:[SDGeneralTool deviceVersion] forHTTPHeaderField:@"zgl-phonetype"];
// NSString *screenString = [NSString stringWithFormat:@"%.0fx%.0f",[UIScreen mainScreen].bounds.size.width * [UIScreen mainScreen].scale,[UIScreen mainScreen].bounds.size.height * [UIScreen mainScreen].scale];
// [manager.requestSerializer setValue:screenString forHTTPHeaderField:@"zgl-resolution"];
if ([OffcnBaseNetworking sharedInstance].token.length) {
[manager.requestSerializer setValue:[OffcnBaseNetworking sharedInstance].token forHTTPHeaderField:@"Authorization"];
}else{
[manager.requestSerializer setValue:@"" forHTTPHeaderField:@"Authorization"];
}
// if ([OffcnBaseNetworking sharedInstance].token.length) {
// [manager.requestSerializer setValue:[OffcnBaseNetworking sharedInstance].token forHTTPHeaderField:@"Authorization"];
// }else{
// [manager.requestSerializer setValue:@"" forHTTPHeaderField:@"Authorization"];
// }
}
- (ZYJAFHTTPSessionManager *)manager
......
//
//
//
// OffcnNetworkExecutor.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......@@ -12,13 +12,19 @@
@interface OffcnNetworkExecutor : NSObject
+ (void)cancelAllOperations;
//客户端登陆
//+ (void)requestLoginWithPassword:(NSString *)password nickname:(NSString *)nickname hook:(NSString *)hook extensionDic:(NSDictionary *)extensionDic Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
//检测房间是否启录制
//+ (void)requestPlaybackRecordCheckWithAccount:(NSString *)account Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
//获取图片json
//+ (void)requesImgJsonWithUrlStr:(NSString *)urlStr Finished:(void(^)(BOOL success,id response,NSString *message))finished;
//sendAsynchronousRequest
+ (void)requesImgJsonWithUrlStr:(NSString *)urlStr Finished:(void(^)(BOOL success,id response,NSString *message))finished;
//发送消息
+ (void)requestSendMsgWithMsg_fromID:(NSString *)msg_fromID msg_toID:(NSString *)msg_toID msg_type:(NSInteger)msg_type msg:(NSMutableDictionary *)msgDic Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
//用户信息标记已读
+ (void)requestMarkMsgReadWithMsg_fromID:(NSString *)msg_fromID msg_toID:(NSString *)msg_toID Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
//获取会话未读消息列表
+ (void)requestGetSessionUnreadMsgWithFromID:(NSString *)fromID toID:(NSString *)toID Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
//获取用户最近会话记录
+ (void)requestGetRecentSessionsWithAccid:(NSString *)accid Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
//获取会话历史消息列表
+ (void)requestGetSessionHistoryMsgWithFromID:(NSString *)fromID toID:(NSString *)toID msg_seq:(NSString *)msg_seq Finished:(void(^)(BOOL success,id response,BaseResponse *baseResponse))finished;
......
//
//
//
// OffcnZYJFMDBHandler.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2019/4/9.
// Copyright © 2019年 中公教育. All rights reserved.
......
//
//
//
// OffcnZYJFMDBHandler.m
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2019/4/9.
// Copyright © 2019年 中公教育. All rights reserved.
......
//
//
......@@ -8,7 +8,7 @@
@import Foundation;
static const NSString *OffcnLiveSDKZYJMQTTVersion = @"1.4.3";
static const NSString *OffcnIMSDKiOSZYJMQTTVersion = @"1.4.3";
#define NSLog(format, ...) do { \
fprintf(stderr, "<%s : %d> %s\n", \
......
//
// ViewController.h
// OffcnLiveSDK
// OffcnIMSDKiOS
//
// Created by vockey on 2018/7/25.
// Copyright © 2018年 中公教育. All rights reserved.
......@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#define kOffcnLiveSDK_changeEnvironment @"kOffcnLiveSDK_changeEnvironment"
#define kOffcnIMSDKiOS_changeEnvironment @"kOffcnIMSDKiOS_changeEnvironment"
@interface ViewController : UIViewController
......
#ifndef __OFFCN_IM__TYPES_H__
#define __OFFCN_IM__TYPES_H__
#include <stdio.h>
#ifdef _WIN32
#define ZG_OIM_API_EXPORT __declspec(dllexport)
#define ZG_OIM_API_IMPORT __declspec(dllimport)
#else
#define ZG_OIM_API_EXPORT __attribute__ ((visibility("default")))
#define ZG_OIM_API_IMPORT
#endif
#ifdef __cplusplus
#define ZG_OIM_C_API_EXPORT extern "C" ZG_OIM_API_EXPORT
#define ZG_OIM_C_API_IMPORT extern "C" ZG_OIM_API_IMPORT
#else
#define ZG_OIM_C_API_EXPORT ZG_OIM_API_EXPORT
#define ZG_OIM_C_API_IMPORT ZG_OIM_API_IMPORT
#endif
#ifdef ZG_OIM_SDK_EXPORTS //need define this micro,when build dll, undefine this micro when use this dll
#define ZG_OIM_C_API ZG_OIM_C_API_EXPORT
#else
#define ZG_OIM_C_API ZG_OIM_C_API_IMPORT
#endif
namespace offcn
{
namespace im
{
typedef enum
{
kMsg_Type_Normal, //正常的聊天消息
kMsg_Type_Recv_Confirm, //收到服务端发来的消息确认消息
}OImMsgType;
typedef enum
{
Z_CONN_IM_SRV_OK,
Z_CONN_IM_SRV_FAILED,
Z_CONN_IM_SRV_BROKEN,
Z_DISCONN_IM_SRV_OK,
}OImEventCode;
class OImCoreObserver
{
public:
virtual void OnOImCoreEvent(int code, const char *context) = 0;
virtual void OnOImCoreMessage(const char *message, int len) = 0;
};
}
}
#endif
//
// OIMCore.h
//
// Created by zxl on 2020/8/7.
// Copyright © 2020 zxl. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "oim_types.h"
@protocol OIMCoreDelegate <NSObject>
-(void) OnOImCoreMessageWithMessage:(const char *)message msgLength:(int)len;
-(void) OnOImCoreEventWithCode:(int)code context:(const char *)context;
@end
NS_ASSUME_NONNULL_BEGIN
@interface OIMCoreAdapter : NSObject
@property(nonatomic, readonly) id<OIMCoreDelegate> delegate;
+ (instancetype)sharedOIMCore;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (id)copy NS_UNAVAILABLE;
- (id)mutableCopy NS_UNAVAILABLE;
/**
* 连接服务器
*
* @param params must contain server'ip and port in json format eg:{"server_ip": "xxxx", "server_port": 123}
*/
-(void) ConnectImServerWithParam:(NSString*)param;
/**
* 与服务器断开连接
*/
-(void) DisConnectImServer;
/**
* 发送消息
*
* @param message message data, size less than 256 BYTES
* @param type message's type
*/
-(void) SendUserMessage:(NSString*)message length:(int)len type:(offcn::im::OImMsgType)type;
@end
NS_ASSUME_NONNULL_END
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment