Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OffcnIMSDKiOS
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
opensource
OffcnIMSDKiOS
Commits
5d46688b
Commit
5d46688b
authored
Aug 28, 2020
by
zhangyunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo
parent
cf242c29
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
304 deletions
+39
-304
project.pbxproj
OffcnIMSDKiOS.xcodeproj/project.pbxproj
+1
-1
Main.storyboard
OffcnIMSDKiOS/Base.lproj/Main.storyboard
+11
-0
OffcnIMSDKiOS.h
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.h
+2
-3
OffcnIMSDKiOS.m
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.m
+6
-4
OffcnZYJFMDBHandler.h
...KiOS/Tools-(工具)/OffcnZYJFMDBHandler/OffcnZYJFMDBHandler.h
+7
-52
OffcnZYJFMDBHandler.m
...KiOS/Tools-(工具)/OffcnZYJFMDBHandler/OffcnZYJFMDBHandler.m
+2
-234
ViewController.mm
OffcnIMSDKiOS/ViewController.mm
+10
-10
No files found.
OffcnIMSDKiOS.xcodeproj/project.pbxproj
View file @
5d46688b
...
...
@@ -918,13 +918,13 @@
A9661FEB24EA80A50024EB54
/* ZYJZYJFMDatabaseQueue.m */
,
A9661FEC24EA80A50024EB54
/* ZYJZYJFMDatabaseAdditions.h */
,
A9661FED24EA80A50024EB54
/* ZYJZYJFMDatabasePool.m */
,
A9661FEE24EA80A50024EB54
/* OffcnZYJFMDBHandler.h */
,
A9661FEF24EA80A50024EB54
/* ZYJZYJFMResultSet.h */
,
A9661FF024EA80A50024EB54
/* ZYJZYJFMDatabase.m */
,
A9661FF124EA80A50024EB54
/* ZYJZYJFMDatabaseAdditions.m */
,
A9661FF224EA80A50024EB54
/* ZYJZYJFMDatabaseQueue.h */
,
A9661FF324EA80A50024EB54
/* ZYJZYJFMDatabasePool.h */
,
A9661FF424EA80A50024EB54
/* ZYJZYJFMResultSet.m */
,
A9661FEE24EA80A50024EB54
/* OffcnZYJFMDBHandler.h */
,
A9661FF524EA80A50024EB54
/* OffcnZYJFMDBHandler.m */
,
);
path
=
OffcnZYJFMDBHandler
;
...
...
OffcnIMSDKiOS/Base.lproj/Main.storyboard
View file @
5d46688b
...
...
@@ -117,6 +117,7 @@
<color
key=
"backgroundColor"
white=
"0.66666666669999997"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"30"
id=
"WY2-02-a1H"
/>
<constraint
firstAttribute=
"width"
constant=
"123"
id=
"xf9-UB-b1m"
/>
</constraints>
<state
key=
"normal"
title=
"使用接口发送消息"
/>
<connections>
...
...
@@ -162,6 +163,11 @@
<constraint
firstAttribute=
"height"
constant=
"50"
id=
"h6U-AZ-Ejp"
/>
</constraints>
</imageView>
<textField
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"left"
contentVerticalAlignment=
"center"
borderStyle=
"roundedRect"
placeholder=
"请输入消息内容"
textAlignment=
"natural"
minimumFontSize=
"17"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"9C8-lY-VAg"
>
<rect
key=
"frame"
x=
"143"
y=
"196"
width=
"217"
height=
"34"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<textInputTraits
key=
"textInputTraits"
/>
</textField>
</subviews>
<color
key=
"backgroundColor"
red=
"1"
green=
"1"
blue=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
<constraints>
...
...
@@ -188,7 +194,9 @@
<constraint
firstItem=
"2eb-Vp-qLt"
firstAttribute=
"height"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"height"
id=
"M7d-CM-zWv"
/>
<constraint
firstItem=
"2eb-Vp-qLt"
firstAttribute=
"top"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"bottom"
constant=
"5"
id=
"QLW-Tp-TY4"
/>
<constraint
firstItem=
"bxC-wQ-owS"
firstAttribute=
"height"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"height"
id=
"ROb-ls-OKO"
/>
<constraint
firstItem=
"9C8-lY-VAg"
firstAttribute=
"bottom"
secondItem=
"TnX-iH-azN"
secondAttribute=
"bottom"
id=
"UMk-Jo-juB"
/>
<constraint
firstItem=
"TnX-iH-azN"
firstAttribute=
"leading"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"leading"
constant=
"15"
id=
"UOK-BA-rIV"
/>
<constraint
firstItem=
"9C8-lY-VAg"
firstAttribute=
"leading"
secondItem=
"TnX-iH-azN"
secondAttribute=
"trailing"
constant=
"5"
id=
"XgB-GO-lOM"
/>
<constraint
firstItem=
"Cy1-S1-DPz"
firstAttribute=
"leading"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"leading"
id=
"Y9c-yU-8ZX"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"HDM-va-7kG"
secondAttribute=
"trailing"
id=
"YX6-FQ-G4J"
/>
<constraint
firstItem=
"FOH-XA-D8x"
firstAttribute=
"top"
secondItem=
"2eb-Vp-qLt"
secondAttribute=
"bottom"
constant=
"5"
id=
"ZKE-q9-PH4"
/>
...
...
@@ -198,6 +206,7 @@
<constraint
firstItem=
"uRU-q5-QzB"
firstAttribute=
"height"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"height"
id=
"gfY-7F-lgC"
/>
<constraint
firstItem=
"1dp-RW-FhV"
firstAttribute=
"leading"
secondItem=
"TnX-iH-azN"
secondAttribute=
"leading"
constant=
"1"
id=
"gpR-z2-ljd"
/>
<constraint
firstItem=
"7fD-Hf-Afy"
firstAttribute=
"height"
secondItem=
"TnX-iH-azN"
secondAttribute=
"height"
id=
"j3W-5R-k7D"
/>
<constraint
firstItem=
"9C8-lY-VAg"
firstAttribute=
"height"
secondItem=
"TnX-iH-azN"
secondAttribute=
"height"
multiplier=
"1.13333"
id=
"k7J-W8-ljE"
/>
<constraint
firstItem=
"9JE-Lz-Dma"
firstAttribute=
"leading"
secondItem=
"TnX-iH-azN"
secondAttribute=
"leading"
constant=
"1"
id=
"kqV-nZ-dh4"
/>
<constraint
firstItem=
"HDM-va-7kG"
firstAttribute=
"top"
secondItem=
"a21-3W-10n"
secondAttribute=
"bottom"
id=
"lS8-hA-rmu"
/>
<constraint
firstItem=
"7fD-Hf-Afy"
firstAttribute=
"leading"
secondItem=
"TnX-iH-azN"
secondAttribute=
"leading"
id=
"lea-oR-ecV"
/>
...
...
@@ -206,6 +215,7 @@
<constraint
firstItem=
"1dp-RW-FhV"
firstAttribute=
"top"
secondItem=
"TnX-iH-azN"
secondAttribute=
"bottom"
constant=
"5"
id=
"ta0-ZL-iPP"
/>
<constraint
firstItem=
"Vmx-zP-DRW"
firstAttribute=
"height"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"height"
id=
"uLF-IL-l61"
/>
<constraint
firstItem=
"Vmx-zP-DRW"
firstAttribute=
"leading"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"trailing"
constant=
"10"
id=
"vfp-Yh-YD6"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"9C8-lY-VAg"
secondAttribute=
"trailing"
constant=
"15"
id=
"xJl-HV-EOH"
/>
<constraint
firstItem=
"9JE-Lz-Dma"
firstAttribute=
"top"
secondItem=
"1dp-RW-FhV"
secondAttribute=
"bottom"
constant=
"5"
id=
"xMf-AL-l1H"
/>
<constraint
firstItem=
"01u-sn-4fM"
firstAttribute=
"leading"
secondItem=
"bxC-wQ-owS"
secondAttribute=
"trailing"
constant=
"10"
id=
"xNi-Lk-dWo"
/>
<constraint
firstItem=
"FOH-XA-D8x"
firstAttribute=
"height"
secondItem=
"dRe-f0-gnl"
secondAttribute=
"height"
id=
"yrM-M1-11o"
/>
...
...
@@ -214,6 +224,7 @@
</view>
<connections>
<outlet
property=
"changeEnvironmentBtn"
destination=
"so4-rI-aRi"
id=
"ong-vG-zJ6"
/>
<outlet
property=
"megTextField"
destination=
"9C8-lY-VAg"
id=
"NdF-KZ-ejC"
/>
<outlet
property=
"showImage"
destination=
"01u-sn-4fM"
id=
"Tl0-7d-FXH"
/>
</connections>
</viewController>
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.h
View file @
5d46688b
//
//
...
...
@@ -59,12 +59,11 @@ typedef void(^OffcnSDKReachabilityStatusCallBack)(OffcnSDKReachabilityStatus sta
/// 发送消息
/// @param msg_fromID 发送人ID
/// @param msg_toID 接收人ID
/// @param tid 本地的消息Id
/// @param msg_type 发送消息类型
/// @param text 文本
/// @param filePath 图片/音频(语音消息格式,只能是aac格式)/视频/文件,沙盒路径
/// @param finished 结果回调
-
(
void
)
sendMsgWithMsg_fromID
:(
NSString
*
)
msg_fromID
msg_toID
:(
NSString
*
)
msg_toID
tid
:(
NSString
*
)
tid
msg_type
:(
OffcnSDKMsgType
)
msg_type
text
:(
NSString
*
)
text
filePath
:(
NSString
*
)
filePath
Finished
:(
void
(
^
)(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
))
finished
;
-
(
void
)
sendMsgWithMsg_fromID
:(
NSString
*
)
msg_fromID
msg_toID
:(
NSString
*
)
msg_toID
msg_type
:(
OffcnSDKMsgType
)
msg_type
text
:(
NSString
*
)
text
filePath
:(
NSString
*
)
filePath
Finished
:(
void
(
^
)(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
))
finished
;
/// 用户信息标记已读
/// @param msg_fromID 发送人ID
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSDKiOS.m
View file @
5d46688b
//
//
...
...
@@ -110,15 +110,17 @@ static OffcnIMSDKiOS *liveTelecastSDK;
#pragma mark - 操作事件
//发送消息
-
(
void
)
sendMsgWithMsg_fromID
:
(
NSString
*
)
msg_fromID
msg_toID
:
(
NSString
*
)
msg_toID
tid
:
(
NSString
*
)
tid
msg_type
:
(
OffcnSDKMsgType
)
msg_type
text
:
(
NSString
*
)
text
filePath
:
(
NSString
*
)
filePath
Finished
:
(
void
(
^
)(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
))
finished
{
-
(
void
)
sendMsgWithMsg_fromID
:
(
NSString
*
)
msg_fromID
msg_toID
:
(
NSString
*
)
msg_toID
msg_type
:
(
OffcnSDKMsgType
)
msg_type
text
:
(
NSString
*
)
text
filePath
:
(
NSString
*
)
filePath
Finished
:
(
void
(
^
)(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
))
finished
{
KWeakSelf
NSString
*
tidStr
=
[
NSString
stringWithFormat
:
@"%@_%@"
,
msg_toID
,[
SDGeneralTool
getNowSSSTimeTimestamp
]];
if
(
msg_type
==
OffcnSDKMsgTypeText
)
{
if
(
!
text
||
!
text
.
length
)
{
text
=
@""
;
}
NSMutableDictionary
*
dataDic
=
[
NSMutableDictionary
dictionaryWithObject
:
text
forKey
:
@"msg"
];
[
OffcnNetworkExecutor
requestSendMsgWithMsg_fromID
:
msg_fromID
msg_toID
:
msg_toID
msg_type
:
msg_type
tid
:
tid
msg
:
dataDic
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
BaseResponse
*
baseResponse
)
{
[
OffcnNetworkExecutor
requestSendMsgWithMsg_fromID
:
msg_fromID
msg_toID
:
msg_toID
msg_type
:
msg_type
tid
:
tid
Str
msg
:
dataDic
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
BaseResponse
*
baseResponse
)
{
finished
(
success
,
sendMsgModel
,
baseResponse
.
errorMessage
);
}];
...
...
@@ -189,7 +191,7 @@ static OffcnIMSDKiOS *liveTelecastSDK;
[
dataDic
setObjectOnSafe
:[
NSNumber
numberWithLongLong
:
folderSize
]
forKey
:
@"size"
];
}
[
OffcnNetworkExecutor
requestSendMsgWithMsg_fromID
:
msg_fromID
msg_toID
:
msg_toID
msg_type
:
msg_type
tid
:
tid
msg
:
dataDic
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
BaseResponse
*
baseResponse
)
{
[
OffcnNetworkExecutor
requestSendMsgWithMsg_fromID
:
msg_fromID
msg_toID
:
msg_toID
msg_type
:
msg_type
tid
:
tid
Str
msg
:
dataDic
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
BaseResponse
*
baseResponse
)
{
finished
(
success
,
sendMsgModel
,
baseResponse
.
errorMessage
);
}];
...
...
OffcnIMSDKiOS/Tools-(工具)/OffcnZYJFMDBHandler/OffcnZYJFMDBHandler.h
View file @
5d46688b
//
//
...
...
@@ -9,63 +9,18 @@
#import <Foundation/Foundation.h>
#import "ZYJZYJFMDB.h"
@interface
FMDBSensitiveWordsModel
:
NSObject
@property
(
nonatomic
,
copy
)
NSString
*
wordsBase64
;
@property
(
nonatomic
,
copy
)
NSString
*
originalWords
;
@end
//获取数据库中历史消息记录
typedef
void
(
^
getFMDBHistoryMessagesBlock
)(
NSArray
*
messagesArray
);
typedef
NS_ENUM
(
NSInteger
,
UIClearStyle
)
{
UIClearStyleAll
=
2
,
//删除list和具体聊天内容
UIClearStylePart
=
3
,
//只删除聊天内容 , list记录不删除
UIClearStyleList
=
4
//删除系统消息等
};
typedef
void
(
^
ReturnData
)(
NSMutableArray
*
modelArr
);
typedef
void
(
^
callBackIsSuccess
)(
BOOL
isSuccess
);
@interface
OffcnZYJFMDBHandler
:
NSObject
@property
(
nonatomic
,
strong
)
ZYJZYJFMDatabaseQueue
*
database
;
@property
(
nonatomic
,
strong
)
ZYJZYJFMDatabaseQueue
*
gongGaoDataBase
;
+
(
OffcnZYJFMDBHandler
*
)
sharedInstance
;
//获取用户聊天数据库
-
(
void
)
getUserDBWithItemSqlitePath
:(
NSString
*
)
itemSqlitePath
;
/**
查询聊天记录(time正叙排序)
@param time 从第几秒开始查询
@param limit 时间范围
@param messagesBack callback
*/
-
(
void
)
getChatInfoArrayWithTime
:(
NSString
*
)
time
limit
:(
NSString
*
)
limit
callback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
/**
查询聊天记录(seek获取当前时间之前的)
@param time 从第几秒开始查询
@param limit 时间范围
@param messagesBack callback
*/
-
(
void
)
getChatInfoArrayFromTime
:(
NSString
*
)
time
limit
:(
NSString
*
)
limit
callback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
/**
查询所有聊天记录(time正叙排序)
@param messagesBack callback
*/
-
(
void
)
getChatInfoAllDataArrayCallback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
//公告
-
(
void
)
getUserGongGaoDBWithItemSqlitePath
:(
NSString
*
)
itemSqlitePath
;
-
(
void
)
getGongGaoArrayWithTime
:(
NSString
*
)
time
limit
:(
NSString
*
)
limit
callback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
-
(
void
)
getGongGaoArrayFromTime
:(
NSString
*
)
time
limit
:(
NSString
*
)
limit
callback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
-
(
void
)
getGongGaoAllDataArrayCallback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
//聊天本地数据库
-
(
void
)
createChatDB
;
-
(
void
)
deleteSensitiveWordsDataTable
;
-
(
void
)
updateSensitiveWords
:(
FMDBSensitiveWordsModel
*
)
model
callBack
:(
callBackIsSuccess
)
isSuccess
;
-
(
void
)
getSensitiveWordsArrayWithWordsBase64
:(
NSString
*
)
wordsBase64
callback
:(
getFMDBHistoryMessagesBlock
)
messagesBack
;
@end
OffcnIMSDKiOS/Tools-(工具)/OffcnZYJFMDBHandler/OffcnZYJFMDBHandler.m
View file @
5d46688b
//
//
...
...
@@ -8,16 +8,12 @@
#import "OffcnZYJFMDBHandler.h"
@implementation
FMDBSensitiveWordsModel
@end
@interface
OffcnZYJFMDBHandler
()
@property
(
nonatomic
,
strong
)
ZYJZYJFMDatabaseQueue
*
chatDBDatabase
;
@end
@implementation
OffcnZYJFMDBHandler
static
OffcnZYJFMDBHandler
*
FMDBHandler
;
+
(
OffcnZYJFMDBHandler
*
)
sharedInstance
{
static
dispatch_once_t
onceToken
;
...
...
@@ -34,156 +30,6 @@ static OffcnZYJFMDBHandler *FMDBHandler;
return
self
;
}
-
(
void
)
getUserDBWithItemSqlitePath
:
(
NSString
*
)
itemSqlitePath
{
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([
fileManager
fileExistsAtPath
:
itemSqlitePath
])
{
_database
=
[
ZYJZYJFMDatabaseQueue
databaseQueueWithPath
:
itemSqlitePath
];
}
}
//@"SELECT * FROM xyu_room_chat order by time asc limit ?,?"
//ZYJFMResultSet *rs = [db executeQuery:sql,time,limit];
-
(
void
)
getChatInfoArrayWithTime
:
(
NSString
*
)
time
limit
:
(
NSString
*
)
limit
callback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_database
)
{
return
;
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM xyu_room_chat WHERE time==?"
];
[
_database
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
,
time
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调历史消息记录
if
(
messagesBack
)
{
messagesBack
(
tmpArray
);
}
}];
}
-
(
void
)
getChatInfoArrayFromTime
:
(
NSString
*
)
time
limit
:
(
NSString
*
)
limit
callback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_database
)
{
return
;
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM xyu_room_chat WHERE time<=? order by time asc"
];
[
_database
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
,
time
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调历史消息记录
if
(
messagesBack
)
{
// NSArray *reversedArray = [[tmpArray reverseObjectEnumerator] allObjects];
messagesBack
(
tmpArray
);
}
}];
}
-
(
void
)
getChatInfoAllDataArrayCallback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_database
)
{
return
;
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM xyu_room_chat order by time asc"
];
[
_database
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调历史消息记录
if
(
messagesBack
)
{
messagesBack
(
tmpArray
);
}
}];
}
-
(
void
)
getUserGongGaoDBWithItemSqlitePath
:
(
NSString
*
)
itemSqlitePath
{
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([
fileManager
fileExistsAtPath
:
itemSqlitePath
])
{
_gongGaoDataBase
=
[
ZYJZYJFMDatabaseQueue
databaseQueueWithPath
:
itemSqlitePath
];
}
}
-
(
void
)
getGongGaoArrayWithTime
:
(
NSString
*
)
time
limit
:
(
NSString
*
)
limit
callback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_gongGaoDataBase
)
{
return
;
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM xyu_announce WHERE time==? order by time desc"
];
[
_gongGaoDataBase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
,
time
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调历史消息记录
if
(
messagesBack
)
{
messagesBack
(
tmpArray
);
}
}];
}
-
(
void
)
getGongGaoArrayFromTime
:
(
NSString
*
)
time
limit
:
(
NSString
*
)
limit
callback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_gongGaoDataBase
)
{
return
;
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM xyu_announce WHERE time<=? order by time desc"
];
[
_gongGaoDataBase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
,
time
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调历史消息记录
if
(
messagesBack
)
{
// NSArray *reversedArray = [[tmpArray reverseObjectEnumerator] allObjects];
messagesBack
(
tmpArray
);
}
}];
}
-
(
void
)
getGongGaoAllDataArrayCallback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_gongGaoDataBase
)
{
return
;
}
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"SELECT * FROM xyu_announce order by time desc"
];
[
_gongGaoDataBase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调历史消息记录
if
(
messagesBack
)
{
messagesBack
(
tmpArray
);
}
}];
}
#pragma mark - 聊天本地数据库
//创建聊天本地数据库
NS_INLINE
ZYJZYJFMDatabaseQueue
*
getFMDBInstance
(){
...
...
@@ -192,82 +38,4 @@ NS_INLINE ZYJZYJFMDatabaseQueue * getFMDBInstance(){
ZYJZYJFMDatabaseQueue
*
database
=
[
ZYJZYJFMDatabaseQueue
databaseQueueWithPath
:
filePath
];
return
database
;
}
-
(
void
)
createChatDB
{
_chatDBDatabase
=
getFMDBInstance
();
[
self
createTable
];
}
-
(
void
)
createTable
{
if
(
!
_chatDBDatabase
)
{
_chatDBDatabase
=
getFMDBInstance
();
}
// [self deleteSensitiveWordsDataTable];
//敏感词更新表
NSString
*
creatSensitiveWordsSqlStr
=
@"create table sensitiveWords(wordsBase64 varchar(1000000),originalWords varchar(1000000));"
;
[
_chatDBDatabase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
if
(
!
[
db
tableExists
:
@"sensitiveWords"
])
{
BOOL
resCreatSensitiveWordsSqlStr
=
[
db
executeUpdate
:
creatSensitiveWordsSqlStr
];
if
(
!
resCreatSensitiveWordsSqlStr
)
{
NSLog
(
@"error when creating database table"
);
NSLog
(
@"%d"
,
db
.
lastErrorCode
);
NSLog
(
@"%@"
,
db
.
lastErrorMessage
);
}
}
}];
}
-
(
void
)
deleteSensitiveWordsDataTable
{
if
(
!
_chatDBDatabase
)
{
_chatDBDatabase
=
getFMDBInstance
();
}
NSString
*
sqlSensitiveWordsStr
=
@"DROP TABLE sensitiveWords"
;
[
_chatDBDatabase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
BOOL
resSensitiveWordsSqlStr
=
[
db
executeUpdate
:
sqlSensitiveWordsStr
];
if
(
!
resSensitiveWordsSqlStr
)
{
NSLog
(
@"error when drop database table"
);
NSLog
(
@"%d"
,
db
.
lastErrorCode
);
NSLog
(
@"%@"
,
db
.
lastErrorMessage
);
}
}];
}
-
(
void
)
updateSensitiveWords
:
(
FMDBSensitiveWordsModel
*
)
model
callBack
:
(
callBackIsSuccess
)
isSuccess
{
if
(
!
_chatDBDatabase
)
{
_chatDBDatabase
=
getFMDBInstance
();
}
[
_chatDBDatabase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
//插入记录到表中
NSString
*
sqlStr
=
@"update sensitiveWords set originalWords = ? where wordsBase64 = ?"
;
BOOL
result
=
[
db
executeUpdate
:
sqlStr
,
model
.
originalWords
,
model
.
wordsBase64
];
if
(
!
result
)
{
NSLog
(
@"error when insert into database table"
);
NSLog
(
@"%d"
,
db
.
lastErrorCode
);
NSLog
(
@"%@"
,
db
.
lastErrorMessage
);
}
if
(
isSuccess
)
{
isSuccess
(
result
);
}
}];
}
-
(
void
)
getSensitiveWordsArrayWithWordsBase64
:
(
NSString
*
)
wordsBase64
callback
:
(
getFMDBHistoryMessagesBlock
)
messagesBack
{
if
(
!
_chatDBDatabase
)
{
_chatDBDatabase
=
getFMDBInstance
();
}
NSString
*
sql
=
@"SELECT * FROM sensitiveWords where wordsBase64 = ?"
;
[
_chatDBDatabase
inDatabase
:
^
(
ZYJZYJFMDatabase
*
db
)
{
ZYJZYJFMResultSet
*
rs
=
[
db
executeQuery
:
sql
,
wordsBase64
];
NSMutableArray
*
tmpArray
=
[
NSMutableArray
array
];
while
([
rs
next
])
{
[
tmpArray
addObject
:
rs
.
resultDictionary
];
}
//回调匹配的敏感词
if
(
messagesBack
)
{
messagesBack
(
tmpArray
);
}
}];
}
@end
OffcnIMSDKiOS/ViewController.mm
View file @
5d46688b
...
...
@@ -9,15 +9,12 @@
#import "ViewController.h"
#import "OffcnIMSDKiOS.h"
#import "OffcnIMSocketManager.h"
#import "OffcnNetworkExecutor.h"
#import "SDGeneralTool.h"
#import "OffcnZYJTestDataStorageView.h"
@interface
ViewController
()
<
UINavigationControllerDelegate
,
UIImagePickerControllerDelegate
>
@property
(
weak
,
nonatomic
)
IBOutlet
UIButton
*
changeEnvironmentBtn
;
@property
(
weak
,
nonatomic
)
IBOutlet
UITextField
*
megTextField
;
@property
(
strong
,
nonatomic
)
NSString
*
fromId
;
@property
(
strong
,
nonatomic
)
NSString
*
toId
;
...
...
@@ -93,9 +90,12 @@
-
(
IBAction
)
sendMeg
:(
UIButton
*
)
sender
{
//发送消息
if
(
!
self
.
megTextField
.
text
.
length
)
{
[
self
tipMessageWithTitle
:
@"请输入消息再发送"
message
:
@""
];
return
;
}
__weak
typeof
(
self
)
weakSelf
=
self
;
NSString
*
tidStr
=
[
NSString
stringWithFormat
:
@"%@_%@"
,
self
.
toId
,[
SDGeneralTool
getNowSSSTimeTimestamp
]];
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
tid
:
tidStr
msg_type
:
OffcnSDKMsgTypeText
text
:
@"你好"
filePath
:
nil
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
)
{
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
msg_type
:
OffcnSDKMsgTypeText
text
:
self
.
megTextField
.
text
filePath
:
nil
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
)
{
if
(
success
)
{
[
weakSelf
tipMessageWithTitle
:
@"发送消息成功"
message
:
@""
];
...
...
@@ -225,9 +225,8 @@
-
(
IBAction
)
uploadFile
:(
UIButton
*
)
sender
{
//上传
__weak
typeof
(
self
)
weakSelf
=
self
;
NSString
*
tidStr
=
[
NSString
stringWithFormat
:
@"%@_%@"
,
self
.
toId
,[
SDGeneralTool
getNowSSSTimeTimestamp
]];
NSString
*
filePath
=
[
self
getImagePath
:
self
.
pickImage
];
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
tid
:
tidStr
msg_type
:
OffcnSDKMsgTypePicture
text
:
nil
filePath
:
filePath
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
)
{
[[
OffcnIMSDKiOS
defaultService
]
sendMsgWithMsg_fromID
:
self
.
fromId
msg_toID
:
self
.
toId
msg_type
:
OffcnSDKMsgTypePicture
text
:
nil
filePath
:
filePath
Finished
:^
(
BOOL
success
,
OffcnIMSendMsgModel
*
sendMsgModel
,
NSString
*
errorMessage
)
{
if
(
success
)
{
[
weakSelf
tipMessageWithTitle
:
@"上传成功"
message
:
@""
];
...
...
@@ -300,9 +299,10 @@
}
-
(
void
)
tipMessageWithTitle
:
(
NSString
*
)
title
message
:
(
NSString
*
)
message
{
__weak
typeof
(
self
)
weakSelf
=
self
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
title
message
:
message
delegate
:
s
elf
cancelButtonTitle
:
@"取消"
otherButtonTitles
:
@"确定"
,
nil
];
[
weakSelf
.
view
endEditing
:
YES
];
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
title
message
:
message
delegate
:
weakS
elf
cancelButtonTitle
:
@"取消"
otherButtonTitles
:
@"确定"
,
nil
];
[
alert
show
];
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment