This commit is contained in:
tangtaoit 2023-05-25 10:32:00 +08:00
commit 7b0c1bc743
148 changed files with 7640 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

9
README.md Normal file
View File

@ -0,0 +1,9 @@
LiMaoIM 即时通讯的iOS SDK 详细使用请参考
http://docs.limaoim.cn/
pod spec lint --verbose
pod trunk push LiMaoIMSDK.podspec --allow-warnings

27
WuKongIMSDK.podspec Normal file
View File

@ -0,0 +1,27 @@
Pod::Spec.new do |s|
s.name = 'WuKongIMSDK'
s.version = '1.0.0'
s.summary = '悟空IM是一款简单高效支持完全私有化的即时通讯.'
s.license = {"type"=>"MIT", "file"=>"ios/LICENSE"}
s.authors = {"tangtaoit"=>"tt@tgo.ai"}
s.homepage = 'https://githubim.com'
s.description = '悟空IM是一款简单高效支持完全私有化的即时通讯提供群聊点对点通讯解决方案'
s.frameworks = ["UIKit", "MapKit","AVFoundation"]
# s.libraries = ["opencore-amrnb", "opencore-amrwb", "vo-amrwbenc"]
s.ios.libraries = ['c++','sqlite3','z']
s.source = { :git => "https://gitee.com/WuKongIM/WuKongIMiOSSDK-Framework.git",:tag => "#{s.version}" }
s.requires_arc = true
s.ios.deployment_target = '12.0'
s.platform = :ios, '12.0'
s.resource = 'ios/WuKongIMSDK.framework/WuKongIMSDK.bundle'
s.vendored_frameworks = 'ios/WuKongIMSDK.framework'
s.xcconfig = {
'OTHER_LDFLAGS' => '-ObjC',
"LIBRARY_SEARCH_PATHS"=>"${PODS_ROOT}/../../WuKongIMiOSSDK-Framework/ios/lib",
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64',
}
s.dependency 'CocoaAsyncSocket', '~> 7.6.4'
s.dependency 'FMDB/SQLCipher', '~>2.7.5'
s.dependency '25519', '~>2.0.2'
end

BIN
ios/.DS_Store vendored Normal file

Binary file not shown.

201
ios/LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,27 @@
//
// WKAESUtil.h
// WuKongIMSDK
//
// Created by tt on 2021/2/25.
//
#import <UIKit/UIKit.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonCryptor.h>
/**
* AES工具类
*/
@interface WKAESUtil : NSObject
/**
* AES加密
*/
+ (NSString *)aesEncrypt:(NSString *)sourceStr key:(NSString*)key iv:(NSString*)iv;
/**
* AES解密
*/
+ (NSString *)aesDecrypt:(NSString *)secretStr key:(NSString*)key iv:(NSString*)iv;
@end

View File

@ -0,0 +1,26 @@
//
// WKBaseTask.h
// WuKongIMSDK
//
// Created by tt on 2020/1/16.
//
#import <Foundation/Foundation.h>
#import "WKTaskProto.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKBaseTask : NSObject<WKTaskProto>
/**
*/
@property(nullable,nonatomic,strong) NSError *error;
/**
*/
@property(nonatomic,assign) CGFloat progress;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,30 @@
//
// WKCMDContent.h
// WuKongIMSDK
//
// Created by tt on 2020/1/31.
//
#import "WKMediaMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKCMDContent : WKMessageContent
/**
cmd
*/
@property(nonatomic,copy) NSString *cmd;
/**
cmd参数
*/
@property(nonatomic,copy) id param;
// cmd验证字段 ,校验是否是服务端下发
@property(nonatomic,copy) NSString *sign; // 签名字符串签出来的sign
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,50 @@
//
// WKCMDDB.h
// WuKongIMSDK-WuKongIMSDK
//
// Created by tt on 2020/11/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKCMDMessage : NSObject
@property(nonatomic,assign) NSInteger mid;
/// 客户端消息唯一编号(相同clientMsgNo被认为是重复消息)
@property(nonatomic,copy) NSString *clientMsgNo;
// 消息ID全局唯一
@property(nonatomic,assign) uint64_t messageId;
// 消息序列号(用户唯一,有序)
@property(nonatomic,assign) uint32_t messageSeq;
// 消息时间(服务器时间,单位秒)
@property(nonatomic,assign) NSInteger timestamp;
@property(nonatomic,copy) NSString *cmd;
@property(nonatomic,copy) NSString *param;
// 是否为系统cmd消息
-(BOOL) same:(WKCMDMessage*)cmdMessage;
@end
@interface WKCMDDB : NSObject
+ (WKCMDDB *)shared;
-(uint32_t) getMaxMessageSeq;
-(void) replaceCMDMessages:(NSArray<WKCMDMessage*>*)messages;
-(NSArray<WKCMDMessage*>*) queryAllCMDMessages;
-(void) deleteCMDMessagesWithIDs:(NSArray<NSNumber*>*) ids;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,56 @@
//
// WKCMDManager.h
// WuKongIMSDK
//
// Created by tt on 2020/10/7.
//
#import <Foundation/Foundation.h>
#import "WKSyncConversationModel.h"
@class WKCMDManager;
NS_ASSUME_NONNULL_BEGIN
@protocol WKCMDManagerDelegate <NSObject>
@optional
/// 收到命令
/// @param manager <#manager description#>
/// @param model <#model description#>
-(void) cmdManager:(WKCMDManager*)manager onCMD:(WKCMDModel*)model;
@end
@interface WKCMDManager : NSObject
// 设置验证cmd的公钥
@property(nonatomic,copy) NSString *pubKey;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKCMDManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKCMDManagerDelegate>) delegate;
/// 调用接受命令委托
/// @param model <#model description#>
-(void) callOnCMDDelegate:(WKCMDModel*)model;
// 拉取cmd消息
-(void) pullCMDMessages;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,33 @@
//
// WKChannel.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKChannel : NSObject<NSCopying>
// 频道ID
@property(nonatomic,copy) NSString *channelId;
// 频道类型
@property(nonatomic,assign) uint8_t channelType;
-(instancetype) initWith:(NSString*)channelId channelType:(uint8_t)channelType;
+(instancetype) channelID:(NSString*)channelId channelType:(uint8_t)channelType;
// 群频道
+(instancetype) groupWithChannelID:(NSString*)channelID;
// 个人频道
+(instancetype) personWithChannelID:(NSString*)channelID;
// 转换为map
-(NSDictionary*) toMap;
// 从map初始化
+(WKChannel*) fromMap:(NSDictionary*)dict;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,147 @@
//
// WKChannelInfo.h
// WuKongIMSDK
//
// Created by tt on 2019/12/23.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
#import "WKConst.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKChannelInfoFollowStrange = 0, // 未关注
WKChannelInfoFollowFriend = 1, // 已关注
WKChannelInfoFollowAll = 2,
} WKChannelInfoFollow;
// 扩展字段的key
typedef NSString *WKChannelExtraKey NS_STRING_ENUM;
@interface WKChannelInfo : NSObject<NSCopying>
// 频道
@property(nonatomic,strong) WKChannel *channel;
// 父类频道
@property(nonatomic,strong,nullable) WKChannel *parentChannel;
/**
0. 1.
*/
@property(nonatomic,assign) WKChannelInfoFollow follow;
@property(nonatomic,assign) BOOL beDeleted; // 是否被对方删除 (好友单向删除)
@property(nonatomic,assign) BOOL beBlacklist; // 是否被对方拉入黑名单
/**
*/
@property(nonatomic,copy) NSString *name;
/**
*/
@property(nonatomic,copy) NSString *remark;
/// 展示的名字如果remark为空则显示name如果remark有值则显示remark
@property(nonatomic,copy) NSString *displayName;
/**
*/
@property(nonatomic,copy) NSString *notice;
/**
logo
*/
@property(nonatomic,copy) NSString *logo;
/**
*/
@property(nonatomic,assign) BOOL stick;
/**
*/
@property(nonatomic,assign) BOOL mute;
/**
*/
@property(nonatomic,assign) BOOL showNick;
/**
*/
@property(nonatomic,assign) BOOL save;
/// 是否全员禁言
@property(nonatomic,assign) BOOL forbidden;
/// 群聊邀请确认
@property(nonatomic,assign) BOOL invite;
/**
*/
@property(nonatomic,assign) long long version;
/// 频道状态 0.正常 2.黑名单
@property(nonatomic,assign) NSInteger status;
/// 是否开启已读回执
@property(nonatomic,assign) BOOL receipt;
/// 是否开启了阅后即焚
@property(nonatomic,assign) BOOL flame;
@property(nonatomic,assign) NSInteger flameSecond; // 开启阅后即焚的秒数
/// 是否是机器人
@property(nonatomic,assign) BOOL robot;
/// 频道类别
@property(nonatomic,copy) NSString *category;
/// 是否在线
@property(nonatomic,assign) BOOL online;
// 在线的主设备
@property(nonatomic,assign) WKDeviceFlagEnum deviceFlag;
/// 最后一次离线时间
@property(nonatomic,assign) NSTimeInterval lastOffline;
/**
*/
@property(nonatomic,strong) NSMutableDictionary<WKChannelExtraKey,id> *extra;
/// 获取扩展字段内的值
/// @param key <#key description#>
-(id) extraValueForKey:(WKChannelExtraKey)key;
-(id) extraValueForKey:(WKChannelExtraKey)key defaultValue:(id _Nullable)value;
-(void) setExtraValue:(id)value forKey:(WKChannelExtraKey)key;
-(BOOL) settingForKey:(WKChannelExtraKey)key defaultValue:(BOOL)on;
-(void) setSettingValue:(BOOL)on forKey:(WKChannelExtraKey)key;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,135 @@
//
// WKChannelInfoDB.h
// WuKongIMSDK
//
// Created by tt on 2019/12/23.
//
#import <Foundation/Foundation.h>
#import "WKChannelInfo.h"
#import "WKDB.h"
#import "WKChannelInfoSearchResult.h"
#import "WKChannelMessageSearchResult.h"
NS_ASSUME_NONNULL_BEGIN
// 频道在线状态
typedef enum : NSUInteger {
WKOnlineStatusOffline, // 离线
WKOnlineStatusOnline, // 在线
} WKOnlineStatus;
// 频道状态
typedef enum : NSUInteger {
WKChannelStatusUnkown,
WKChannelStatusNormal,
WKChannelStatusBlacklist,
} WKChannelStatus;
@interface WKChannelInfoDB : NSObject
+ (WKChannelInfoDB *)shared;
/**
@param channelInfo
@return <#return value description#>
*/
-(BOOL) saveChannelInfo:(WKChannelInfo*)channelInfo;
/**
@param channelInfos <#channelInfos description#>
@return
*/
-(NSArray<WKChannelInfo*>*) addOrUpdateChannelInfos:(NSArray<WKChannelInfo*>*)channelInfos;
/**
@param channelInfo <#channelInfo description#>
*/
-(void) updateChannelInfo:(WKChannelInfo*)channelInfo;
/// 更新在线状态
/// @param channel 指定的频道
/// @param status 在线状态
/// @param lastOffline 最后一次离线时间
-(void) updateChannelOnlineStatus:(WKChannel*)channel status:(WKOnlineStatus)status lastOffline:(NSTimeInterval)lastOffline;
/**
线
@param channel
@param status 线
@param lastOffline 线
@param mainDeviceFlag 线
*/
-(void) updateChannelOnlineStatus:(WKChannel*)channel status:(WKOnlineStatus)status lastOffline:(NSTimeInterval)lastOffline mainDeviceFlag:(WKDeviceFlagEnum)mainDeviceFlag;
/// 删除频道信息
/// @param channel <#channel description#>
-(void) deleteChannelInfo:(WKChannel*)channel;
/**
@param channel
@return <#return value description#>
*/
-(WKChannelInfo*) queryChannelInfo:(WKChannel*)channel;
-(WKChannelInfo*) queryChannelInfo:(WKChannel*)channel db:(FMDatabase*)db;
/// 通过状态查询频道信息
/// @param status 0.正常 2.黑明单
-(NSArray<WKChannelInfo*>*) queryChannelInfosWithStatus:(WKChannelStatus)status;
/// 通过状态和关注类型查询频道集合
/// @param status 状态
/// @param follow <#follow description#>
-(NSArray<WKChannelInfo*>*) queryChannelInfosWithStatusAndFollow:(WKChannelStatus)status follow:(WKChannelInfoFollow)follow;
/// 获取跟我好友关系的频道数据
/// @param keyword 关键字
/// @param limit 数量限制
-(NSArray<WKChannelInfo*>*) queryChannelInfoWithFriend:(NSString*)keyword limit:(NSInteger)limit;
/// 查询所有在线的频道
-(NSArray<WKChannelInfo*>*) queryChannelOnlines;
/// 搜索频道信息
/// @param keyword 频道关键字
/// @param channelType 频道类型
/// @param limit 数量限制
-(NSArray<WKChannelInfoSearchResult*>*) searchChannelInfoWithKeyword:(NSString*)keyword channelType:(uint8_t)channelType limit:(NSInteger)limit;
/// 搜索频道信息
/// @param keyword 频道关键字
/// @param limit 数量限制
-(NSArray<WKChannelMessageSearchResult*>*) searchChannelMessageWithKeyword:(NSString*)keyword limit:(NSInteger)limit;
/// 查询频道
/// @param keyword 关键字
/// @param channelType 频道类型
/// @param limit 数量限制
-(NSArray<WKChannelInfo*>*) queryChannelInfoWithType:(NSString*)keyword channelType:(uint8_t)channelType limit:(NSInteger)limit;
/**
*/
-(NSArray<WKChannelInfo*>*) queryAllConversationChannelInfos;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// WKChannelInfoSearchResult.h
// WuKongIMSDK
//
// Created by tt on 2020/5/8.
//
/**
select t.*,cm.member_name,cm.member_remark from (
select channel.*,max(channel_member.id) mid from channel,channel_member where channel.channel_id=channel_member.channel_id and channel.channel_type=channel_member.channel_type and (channel.name like '%Zz%' or channel.remark like '%Zz%' or channel_member.member_name like '%Zz%' or channel_member.member_remark like '%Zz%')
group by channel.channel_id,channel.channel_type
) t,channel_member cm where t.channel_id=cm.channel_id and t.channel_type=cm.channel_type and t.mid=cm.id
*/
#import <Foundation/Foundation.h>
#import "WKChannelInfo.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKChannelInfoSearchResult : NSObject
// 频道信息
@property(nonatomic,strong) WKChannelInfo *channelInfo;
@property(nonatomic,strong) NSString *containMemberName; // 包含的成员名字,如果有
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,255 @@
//
// WKChannelManager.h
// WuKongIMSDK
//
// Created by tt on 2019/12/23.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
#import "WKChannelInfo.h"
#import "WKChannelMemberDB.h"
#import "WKTaskOperator.h"
NS_ASSUME_NONNULL_BEGIN
@protocol WKChannelManagerDelegate <NSObject>
@optional
/**
@param channelInfo <#channelInfo description#>
*/
-(void) channelInfoUpdate:(WKChannelInfo*)channelInfo;
-(void) channelInfoUpdate:(WKChannelInfo*)channelInfo oldChannelInfo:(WKChannelInfo* __nullable)oldChannelInfo;
/// 频道数据移除
/// @param channel <#channel description#>
-(void) channelInfoDelete:(WKChannel*)channel oldChannelInfo:(WKChannelInfo * __nullable )oldChannelInfo;
@end
typedef void (^WKChannelInfoBlock)(WKChannelInfo*);
@interface WKChannelManager : NSObject
+ (WKChannelManager *)shared;
/**
@param channel
@param channelInfoBlock
*/
-(WKTaskOperator*) fetchChannelInfo:(WKChannel*) channel completion:(_Nullable WKChannelInfoBlock)channelInfoBlock;
-(void) fetchChannelInfo:(WKChannel*) channel;
/**
cell获取频道数据
*/
-(void) addChannelRequest:(WKChannel*)channel complete:(void(^_Nullable)(NSError *error,bool notifyBefore))complete;
/**
*/
-(void) cancelRequest:(WKChannel*)channel;
/**
@param channel
@return <#return value description#>
*/
-(WKChannelInfo*) getChannelInfo:(WKChannel*)channel;
/**
*/
-(WKChannelInfo*) getChannelInfoOfUser:(NSString*)uid;
/**
*/
-(void) deleteChannelInfo:(WKChannel*) channel;
/**
version大于当前库里的version才更新
@param channelInfo <#channelInfo description#>
*/
-(void) addOrUpdateChannelInfoIfNeed:(WKChannelInfo*) channelInfo;
/**
@param channelInfo <#channelInfo description#>
*/
-(void) addOrUpdateChannelInfo:(WKChannelInfo*) channelInfo;
/// 更新频道信息
/// @param channelInfo <#channelInfo description#>
-(void) updateChannelInfo:(WKChannelInfo*) channelInfo;
/// 添加频道信息
/// @param channelInfo <#channelInfo description#>
-(void) addChannelInfo:(WKChannelInfo*) channelInfo;
/**
@param channel
@param setting @{@"mute":@(true)} @{@"mute":@(true),@"stick":@(true)}
*/
-(void) updateChannelSetting:(WKChannel*)channel setting:(NSDictionary*)setting;
/**
()
@param channelInfos <#channelInfos description#>
*/
-(void) addOrUpdateChannelInfos:(NSArray<WKChannelInfo*>*) channelInfos;
/**
@param channel
*/
-(void) deleteMembers:(WKChannel*)channel;
/**
@param members
*/
-(void) addOrUpdateMembers:(NSArray<WKChannelMember*>*)members;
/**
@param channel
@return <#return value description#>
*/
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel;
/**
@param channel
@param limit
*/
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel limit:(NSInteger)limit;
/**
*/
-(NSInteger) getMemberCount:(WKChannel*)channel;
/**
@param channel
@param uid UID
*/
-(WKChannelMember*) getMember:(WKChannel*)channel uid:(NSString*)uid;
/// 是否是管理员(群主或管理员)
/// @param channel <#channel description#>
/// @param uid <#uid description#>
-(BOOL) isManager:(WKChannel*)channel memberUID:(NSString*)uid;
/**
key
@param channel
@return <#return value description#>
*/
-(NSString*) getMemberLastSyncKey:(WKChannel*)channel;
/// 设置频道在线
/// @param channel <#channel description#>
/// @param deviceFlag 设备标记
-(void) setChannelOnline:(WKChannel*)channel deviceFlag:(WKDeviceFlagEnum)deviceFlag;
-(void) setChannelOnline:(WKChannel*)channel;
/// 设置频道离线
/// @param channel <#channel description#>
-(void) setChannelOffline:(WKChannel*)channel;
- (void)setChannelOffline:(WKChannel *)channel deviceFlag:(WKDeviceFlagEnum)deviceFlag;
/// 只更新频道的在线状态
/// @param online <#online description#>
-(void) updateChannelOnlineStatus:(WKChannel*)channel online:(BOOL)online;
/// 设置频道离线
/// @param channel 频道
/// @param lastOffline 最后一次离线时间
/// @param deviceFlag 最后一次离线的设备
- (void)setChannelOffline:(WKChannel *)channel lastOffline:(NSTimeInterval)lastOffline deviceFlag:(WKDeviceFlagEnum)deviceFlag;
-(void) setChannelOffline:(WKChannel*)channel lastOffline:(NSTimeInterval)lastOffline;
/**
@param channelInfo <#channelInfo description#>
*/
-(void) setCache:(WKChannelInfo*) channelInfo;
/**
@return <#return value description#>
*/
-(WKChannelInfo*) getCache:(WKChannel*)channel;
/**
*/
-(WKChannelMember*) getMemberFromCache:(WKChannel *)channel uid:(NSString *)uid;
// 删除频道的成员缓存
-(void) deleteMembersWithChannelFromCache:(WKChannel*)channel;
/**
*/
-(void) removeChannelAllCache;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKChannelManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKChannelManagerDelegate>) delegate;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,169 @@
//
// WKChannelMemberDB.h
// WuKongIMSDK
//
// Created by tt on 2020/1/20.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
// 成员角色
typedef enum : NSUInteger {
WKMemberRoleCommon, // 普通成员
WKMemberRoleCreator, // 创建者
WKMemberRoleManager, // 管理员
} WKMemberRole;
// 成员状态
typedef enum : NSUInteger {
WKMemberStatusUnknown,
WKMemberStatusNormal, // 正常
WKMemberStatusBlacklist, // 被拉入黑名单
} WKMemberStatus;
@interface WKChannelMember : NSObject
@property(nonatomic,copy) NSString *channelId; // 频道ID
@property(nonatomic,assign) uint8_t channelType; // 频道类型
@property(nonatomic,copy) NSString *memberAvatar; // 成员头像
@property(nonatomic,copy) NSString *memberUid; // 成员uid
@property(nonatomic,copy) NSString *memberName; // 成员名称
@property(nonatomic,copy) NSString *memberRemark; // 成员备注
@property(nonatomic,copy,readonly) NSString *displayName;
@property(nonatomic,assign) WKMemberRole role; // 成员角色
@property(nonatomic,assign) WKMemberStatus status; // 成员状态
@property(nonatomic,strong) NSNumber *version; // 版本
@property(nonatomic,strong) NSMutableDictionary *extra; // 扩展字段
@property(nonatomic,strong) NSString *createdAt; // 成员加入时间
@property(nonatomic,strong) NSString *updatedAt; // 成员数据最后一次更新时间
@property(nonatomic,assign) BOOL robot; // 是否是机器人
@property(nonatomic,assign) BOOL isDeleted; // 是否已删除
@end
@interface WKChannelMemberDB : NSObject
+ (WKChannelMemberDB *)shared;
/**
@param members <#members description#>
*/
-(void) addOrUpdateMembers:(NSArray<WKChannelMember*>*)members;
/// 删除频道成员
/// @param channel <#channel description#>
-(void) deleteMembers:(WKChannel*)channel;
/**
key
@param channel
@return <#return value description#>
*/
-(NSString*) getMemberLastSyncKey:(WKChannel*)channel;
/**
@param channel
@return <#return value description#>
*/
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel;
/**
@param channel
@param limit
*/
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel limit:(NSInteger)limit;
/**
@param channel
@param keyword
@page page 1
@param limit
*/
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel keyword:(NSString*)keyword page:(NSInteger)page limit:(NSInteger)limit;
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel role:(WKMemberRole)role;
/// 获取群内的黑名单成员
/// @param channel <#channel description#>
-(NSArray<WKChannelMember*>*) getBlacklistMembersWithChannel:(WKChannel*)channel;
/// 获取管理员和创建者列表
/// @param channel 频道
-(NSArray<WKChannelMember*>*) getManagerAndCreator:(WKChannel*)channel;
/**
uid的成员列表
@param channel <#channel description#>
@param uids <#uids description#>
@return <#return value description#>
*/
-(NSArray<WKChannelMember*>*) getMembersWithChannel:(WKChannel*)channel uids:(NSArray<NSString*>*)uids;
/**
@param status
@param channel
@param uids uid集合
*/
-(void) updateMemberStatus:(WKMemberStatus)status channel:(WKChannel*) channel uids:(NSArray<NSString*>*)uids;
/**
@param channel
@param uid UID
@return <#return value description#>
*/
-(BOOL) isManager:(WKChannel*)channel memberUID:(NSString*)uid;
/**
@param channel
@param uid UID
@return <#return value description#>
*/
-(BOOL) isCreator:(WKChannel*)channel memberUID:(NSString*)uid;
/// 成员是否存在频道里
/// @param channel 频道对象
/// @param uid 成员uid
-(BOOL) exist:(WKChannel*)channel uid:(NSString*)uid;
/**
@param channel
@param uid UID
@return
*/
- (WKChannelMember*)get:(WKChannel*)channel memberUID:(NSString *)uid;
/**
*/
-(NSInteger) getMemberCount:(WKChannel*)channel;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,26 @@
//
// WKMessageSearchResult.h
// WuKongIMSDK
//
// Created by tt on 2020/5/10.
//
#import <Foundation/Foundation.h>
#import "WKChannelInfo.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKChannelMessageSearchResult : NSObject
// 频道信息
@property(nonatomic,strong) WKChannel *channel;
// 消息数量
@property(nonatomic,assign) NSInteger messageCount;
// 客户端序列号
@property(nonatomic,assign) uint32_t orderSeq;
// 消息可搜索内容
@property(nonatomic,copy) NSString *searchableWord;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,22 @@
//
// WKChannelRequestQueue.h
// WuKongIMSDK
//
// Created by tt on 2021/4/22.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKChannelRequestQueue : NSObject
+ (WKChannelRequestQueue *)shared;
-(void) addRequest:(WKChannel*)channel complete:(void(^)(NSError *error,bool notifyBefore))complete;
-(void) cancelRequest:(WKChannel*)channel;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,30 @@
//
// WKChatDataProvider.h
// Pods
//
// Created by tt on 2022/5/27.
//
#import "WKSyncChannelMessageModel.h"
#ifndef WKChatDataProvider_h
#define WKChatDataProvider_h
#endif /* WKChatDataProvider_h */
NS_ASSUME_NONNULL_BEGIN
// 同步频道消息
typedef void(^WKSyncChannelMessageCallback)(WKSyncChannelMessageModel* __nullable syncChannelMessageModel,NSError * __nullable error);
typedef void (^WKSyncChannelMessageProvider)(WKChannel *channel,uint32_t startMessageSeq,uint32_t endMessageSeq,NSInteger limit,WKPullMode pullMode,WKSyncChannelMessageCallback callback);
// 扩展消息
typedef void(^WKSyncMessageExtraCallback)(NSArray<WKMessageExtra*>* __nullable results,NSError * __nullable error);
typedef void(^WKSyncMessageExtraProvider)(WKChannel *channel,long long extraVersion,NSInteger limit,WKSyncMessageExtraCallback callback);
typedef void(^WKUpdateMessageExtraCallback)(NSError *error);
typedef void(^WKUpdateMessageExtraProvider) (WKMessageExtra *newExtra,WKMessageExtra *oldExtra,WKUpdateMessageExtraCallback callback);
// 消息编辑
typedef void(^WKMessageEditCallback)(NSError * __nullable error);
typedef void(^WKMessageEditProvider)(WKMessageExtra *extra,WKMessageEditCallback callback);
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,393 @@
//
// WKChatManager.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
#import "WKMessageContent.h"
#import "WKSendackPacket.h"
#import "WKRecvPacket.h"
#import "WKConversation.h"
#import "WKMessageStatusModel.h"
#import "WKSyncChannelMessageModel.h"
#import "WKSetting.h"
#import "WKMessageExtra.h"
#import "WKChatDataProvider.h"
@protocol WKChatManagerDelegate;
NS_ASSUME_NONNULL_BEGIN
typedef BOOL(^MessageStoreBeforeIntercept)(WKMessage*message);
@interface WKChatManager : NSObject
/**
()
@param content
@param channel
*/
-(WKMessage*) sendMessage:(WKMessageContent*)content channel:(WKChannel*)channel;
/**
()
@param content
@param channel
@param topic
*/
-(WKMessage*) sendMessage:(WKMessageContent*)content channel:(WKChannel*)channel topic:(NSString*)topic;
/**
()
@param content
@param channel
@param setting
*/
-(WKMessage*) sendMessage:(WKMessageContent*)content channel:(WKChannel*)channel setting:(WKSetting * __nullable)setting;
-(WKMessage*) sendMessage:(WKMessageContent*)content channel:(WKChannel*)channel setting:(WKSetting * __nullable)setting topic:(NSString*)topic;
/**
@param message
@return <#return value description#>
*/
-(WKMessage*) sendMessage:(WKMessage*)message;
/// 发送消息
/// @param message 消息对象
/// @param addRetryQueue 是否添加到重试队列如果是true消息发送失败将会进行指定次数的重试
-(WKMessage*) sendMessage:(WKMessage*)message addRetryQueue:(BOOL)addRetryQueue;
/**
@param message
*/
-(WKMessage*) resendMessage:(WKMessage*)message;
/**
()
@param content
@param channel
*/
-(WKMessage*) saveMessage:(WKMessageContent*)content channel:(WKChannel*)channel;
/**
@param content
@param channel
@param fromUid uid
@return <#return value description#>
*/
-(WKMessage*) saveMessage:(WKMessageContent*)content channel:(WKChannel*)channel fromUid:( NSString* __nullable)fromUid;
-(WKMessage*) saveMessage:(WKMessageContent*)content channel:(WKChannel*)channel fromUid:(NSString* __nullable)fromUid status:(WKMessageStatus)status;
/// 保存消息
-(void) saveMessages:(NSArray<WKMessage*>*)messages;
/**
@param content
@param channel
@return <#return value description#>
*/
-(WKMessage*) forwardMessage:(WKMessageContent*)content channel:(WKChannel*)channel;
/**
@param message
@param newContent
*/
-(WKMessage*) editMessage:(WKMessage*)message newContent:(WKMessageContent*)newContent;
/**
@param message
*/
-(void) deleteMessage:(WKMessage*)message;
/**
*/
-(void) deleteMessage:(NSString*)fromUID channel:(WKChannel*)channel;
/**
@param channel
*/
-(void) clearMessages:(WKChannel*)channel;
/// 清除当前用户的所有消息
-(void) clearAllMessages;
/**
maxMsgSeq以前的所有消息
@param channel
@param maxMsgSeq messageSeq
@param isContain maxMsgSeq
*/
- (void) clearFromMsgSeq:(WKChannel*)channel maxMsgSeq:(uint32_t)maxMsgSeq isContain:(BOOL)isContain;
/**
@param channel
@param limit
@param complete
*/
-(void) pullLastMessages:(WKChannel*)channel limit:(int)limit complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete;
/**
@param channel
@param limit
@param complete
@param alwayRequest
*/
-(void) pullLastMessages:(WKChannel*)channel limit:(int)limit alwayRequest:(BOOL)alwayRequest complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete;
/**
@param channel
@param startOrderSeq orderSeq 10010 startOrderSeq就是100 90 91 92 93 94 95 96 97 98 99
@param limit
@param complete
*/
-(void) pullDown:(WKChannel*)channel startOrderSeq:(uint32_t)startOrderSeq limit:(int)limit complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete;
/**
@param startOrderSeq orderSeq 10010 startOrderSeq就是100 101 102 103 104 105 106 107 108 109 110
@param limit
@param complete
*/
-(void) pullUp:(WKChannel*)channel startOrderSeq:(uint32_t)startOrderSeq limit:(int)limit complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete;
/**
orderSeq周围的消息 55 orderSeq 20 16 17 18 19 20 21 22 23 24 25 使
@param channel
@param orderSeq OrderSeq查询周围的消息
*/
-(void) pullAround:(WKChannel*)channel orderSeq:(uint32_t)orderSeq limit:(int)limit complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete;
/**
@param channel
@param startOrderSeq messageSeq messageSeq为基准进行上下浮动查询
@param endOrderSeq messageSeq messageSeq为终止 0 limit限制查询数量
@param limit
@param pullMode
@param complete
*/
-(void) pullMessages:(WKChannel*)channel startOrderSeq:(uint32_t)startOrderSeq endOrderSeq:(uint32_t)endOrderSeq limit:(int)limit pullMode:(WKPullMode)pullMode complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete DEPRECATED_MSG_ATTRIBUTE("use pullDown or pullUp");
/**
@param channel
@param aroundOrderSeq OrderSeq查询周围的消息