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查询周围的消息
*/
-(void) getMessages:(WKChannel*)channel aroundOrderSeq:(uint32_t)aroundOrderSeq limit:(int)limit complete:(void(^)(NSArray<WKMessage*> *messages,NSError *error))complete DEPRECATED_MSG_ATTRIBUTE("use pullAround");;
/**
@param message
*/
-(void) updateMessageVoiceReaded:(WKMessage*)message;
/**
@param message
*/
-(void) updateMessageLocalExtra:(WKMessage*)message;
/**
*/
-(void) updateMessageRemoteExtra:(WKMessage*)message;
/// 撤回消息
/// @param message <#message description#>
-(void) revokeMessage:(WKMessage*)message;
/// 获取orderSeq
/// @param messageSeq <#messageSeq description#>
-(uint32_t) getOrderSeq:(uint32_t)messageSeq;
-(uint32_t) getMessageSeq:(uint32_t) orderSeq;
/**
orderSeq的有效orderSeq
*/
-(uint32_t) getOrNearbyMessageSeq:(uint32_t)orderSeq;
/// 正文包装为消息
/// @param content 消息正文
/// @param channel 频道
/// @param fromUid 发送者UID
-(WKMessage*) contentToMessage:(WKMessageContent*)content channel:(WKChannel*)channel fromUid:(NSString * __nullable)fromUid;
/// 通过正文类型获取content
/// @param contentType 正文类型
-(WKMessageContent*) getMessageContent:(NSInteger)contentType;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKChatManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKChatManagerDelegate>) delegate;
/// 添加消息存储之拦截器
/// @param sid 拦截器唯一ID
/// @param intercept 拦截器 返回true表示消息存储 返回false表示消息不存储
-(void) addMessageStoreBeforeIntercept:(NSString*)sid intercept:(MessageStoreBeforeIntercept)intercept;
/// 移除消息存储之前的拦截器
/// @param sid 拦截器唯一ID
-(void) removeMessageStoreBeforeIntercept:(NSString*)sid;
/// 调用拦截器获得消息是否需要存储
/// @param message <#message description#>
-(BOOL) needStoreOfIntercept:(WKMessage*)message;
/**
*/
-(void) syncMessageExtra:(WKChannel*)channel complete:(void(^_Nullable)(NSError * _Nullable error))complete;
/**
*/
//-(void) markReaded:(WKChannel*)channel messages:(NSArray<WKMessage*>*)messages;
// 获取某个频道内最新的消息
-(WKMessage*) getLastMessage:(WKChannel*)channel;
// 通知UI消息更新
- (void)callMessageUpdateDelegate:(WKMessage*)message;
// 通知UI收到消息
- (void)callRecvMessagesDelegate:(NSArray<WKMessage*>*)messages;
/// 同步频道消息提供者(由第三方设置)
@property(nonatomic,copy) WKSyncChannelMessageProvider syncChannelMessageProvider;
@property(nonatomic,copy) WKSyncMessageExtraProvider syncMessageExtraProvider; // 同步消息扩展
@property(nonatomic,copy) WKUpdateMessageExtraProvider updateMessageExtraProvider; // 更新消息扩展
// 消息编辑提供者
@property(nonatomic,copy) WKMessageEditProvider messageEditProvider;
@end
/**
*/
@protocol WKChatManagerDelegate <NSObject>
@optional
/**
@param message
@param left left为0时再刷新UI
*/
- (void)onRecvMessages:(WKMessage*)message left:(NSInteger)left;
/**
@param message <#message description#>
@param left left为0时再刷新UI
*/
-(void) onMessageUpdate:(WKMessage*) message left:(NSInteger)left;
/**
@param message <#message description#>
@param left left为0时再刷新UI
@param total
*/
-(void) onMessageUpdate:(WKMessage*) message left:(NSInteger)left total:(NSInteger)total;
/**
*/
-(void) onSendack:(WKSendackPacket*) sendackPacket left:(NSInteger)left;
/**
@param message
*/
-(void) onMessageDeleted:(WKMessage*) message;
/**
@param channel <#channel description#>
*/
-(void) onMessageCleared:(WKChannel*)channel;
/// 清除所有消息
-(void) onMessageAllCleared;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,59 @@
//
// WKChatManagerInner.h
// Pods
//
// Created by tt on 2022/5/27.
//
#ifndef WKChatManagerInner_h
#define WKChatManagerInner_h
#endif /* WKChatManagerInner_h */
@interface WKChatManager ()
/**
@param sendackArray <#sendackArray description#>
*/
-(void) handleSendack:(NSArray<WKSendackPacket*> *)sendackArray;
/**
@param packets <#packets description#>
*/
-(void) handleRecv:(NSArray<WKRecvPacket*>*) packets;
/**
-> -> ->
@param messages <#messages description#>
*/
-(void) handleMessages:(NSArray<WKMessage*>*) messages;
// 调用消息状态改变委托
//- (void)callMessageStatusChangeDelegate:(NSArray<WKMessageStatusModel*>*)statusModels;
// 调用消息更新委托
- (void)callMessageUpdateDelegate:(WKMessage*)message left:(NSInteger)left total:(NSInteger)total;
/// 调用收到消息的委托
/// @param messages <#messages description#>
- (void)callRecvMessagesDelegate:(NSArray<WKMessage*>*)messages;
/// 获取所有消息存储之前的拦截器
-(NSArray<MessageStoreBeforeIntercept>*) getMessageStoreBeforeIntercepts;
@end

View File

@ -0,0 +1,35 @@
//
// WKCoder.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKCoder : NSObject
/**
@param packet
@return
*/
-(NSData*) encode:(WKPacket*)packet;
/**
@param data <#data description#>
@return <#return value description#>
*/
-(WKPacket*) decode:(NSData*)data;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,27 @@
//
// WKConnackPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/26.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKConnackPacket : WKPacket<WKPacketBodyCoder>
// 通过客户端的RSA公钥加密的服务端DH公钥
@property(nonatomic,copy) NSString *serverKey;
// 安全吗
@property(nonatomic,copy) NSString *salt;
// 客户端与服务器的时间差值
@property(nonatomic,assign) int64_t timeDiff;
// 连接返回原因代号
@property(nonatomic,assign) uint8_t reasonCode;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,23 @@
//
// WKConnectInfo.h
// WuKongIMSDK
//
// Created by tt on 2020/2/7.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKConnectInfo : NSObject
@property(nonatomic,copy) NSString *uid;
@property(nonatomic,copy) NSString *token;
@property(nonatomic,copy) NSString *name;
@property(nonatomic,copy) NSString *avatar;
+(instancetype) initWithUID:(NSString*)uid token:(NSString*)token name:(NSString*)name avatar:(NSString*)avatar;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
//
// WKConnectPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKConnectPacket : WKPacket<WKPacketBodyCoder>
// 协议版本号
@property(nonatomic,assign) uint8_t version;
// 客户端KEY (base64编码的DH公钥)
@property(nonatomic,copy) NSString *clientKey;
// 用户的唯一uid
@property(nonatomic,copy) NSString *uid;
// 连接凭证token
@property(nonatomic,copy) NSString *token;
// 设备标示 0.app 1.pc
@property(nonatomic,assign) uint8_t deviceFlag;
// 设备ID
@property(nonatomic,copy) NSString *deviceId;
// 客户端当前时间戳(13位时间戳,到毫秒)
@property(nonatomic,assign) uint64_t clientTimestamp;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,110 @@
//
// WKConnectionManager.h
// WuKongIMSDK
//
// Created by tt on 2019/11/23.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKConnectInfo.h"
#import "WKConst.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKNoConnect, // 未连接
WKConnecting, // 连接中
WKPullingOffline, // 拉取离线中
WKConnected, // 已建立连接
WKDisconnected, // 断开连接
} WKConnectStatus;
@protocol WKConnectionManagerDelegate <NSObject>
@optional
/**
*/
-(void) onConnectStatus:(WKConnectStatus)status reasonCode:(WKReason)reasonCode;
/**
@param reasonCode
@param reason
*/
-(void) onKick:(uint8_t)reasonCode reason:(NSString*)reason;
@end
@interface WKConnectionManager : NSObject
+ (WKConnectionManager*)sharedManager;
@property(nonatomic,assign,readonly) WKConnectStatus connectStatus;
/// 获取连接地址
@property(nonatomic,copy) void(^getConnectAddr)(void(^complete)(NSString * __nullable addr));
/**
* IM服务器
*/
-(void) connect;
/**
@param force force设置为true
*/
-(void) disconnect:(BOOL) force;
/// 登出,将强制断开,并清除登录信息
-(void) logout;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKConnectionManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKConnectionManagerDelegate>) delegate;
/**
@param packet <#packet description#>
*/
-(void) sendPacket:(WKPacket*)packet;
/**
ping包
*/
-(void) sendPing;
/**
IM
@param timeout complete
*/
-(void) wakeup:(NSTimeInterval)timeout complete:(void(^__nullable)(NSError * __nullable error))complete;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,93 @@
//
// WKConst.h
// Pods
//
// Created by tt on 2019/11/25.
//
// 正文类型
typedef enum : NSUInteger {
WK_TEXT = 1, // 文本消息
WK_IMAGE = 2, // 图片消息
WK_GIF = 3, // gif表情
WK_VOICE = 4, // 语音消息
WK_SIGNAL_ERROR = 98, // signal解密失败
WK_CMD = 99, // 命令消息
WK_UNKNOWN = 0, // 未知消息
} WKContentType;
// 消息状态
typedef enum : NSUInteger {
WK_MESSAGE_WAITSEND, // 等待发送
WK_MESSAGE_SUCCESS, // 发送成功
WK_MESSAGE_ONLYSAVE, // 仅仅保存消息(不做重发处理)
WK_MESSAGE_UPLOADING, // 上传中
WK_MESSAGE_FAIL, // 发送失败
} WKMessageStatus;
typedef enum : uint8_t {
NONE,
WK_CONNECT = 1, // 客户端请求连接到服务器(c2s)
WK_CONNACK =2, // 服务端收到连接请求后确认的报文(s2c)
WK_SEND = 3, // 发送消息(c2s)
WK_SENDACK = 4, // 收到消息确认的报文(s2c)
WK_RECV = 5, //收取消息(s2c)
WK_RECVACK = 6, // 收取消息确认(c2s)
WK_PING = 7, //ping请求
WK_PONG = 8, // 对ping请求的相应
WK_DISCONNECT = 9 // 断开连接
} WKPacketType;
typedef enum : uint8_t {
WK_REASON_UNKNOWN = 0, // 未知
WK_REASON_SUCCESS = 1, // 认证成功
WK_REASON_AUTHFAIL = 2, // 认证失败一般是token不正确
WK_REASON_IN_BLACKLIST = 4, // 在黑名单内
WK_REASON_KICK = 12, // 被踢
WK_REASON_NOT_IN_WHITELIST = 13, // 没在好友白明单内(说明不是好友)
} WKReason;
// 频道类型
typedef enum : uint8_t {
WK_PERSON = 1, // 个人
WK_GROUP = 2, // 群组
WK_COMMUNITY = 4, // 社区
WK_COMMUNITY_TOPIC = 5, // 社区话题
WK_COMMUNITY_INFO = 6, // 信息频道
} WKChannelType;
// 协议类型
typedef enum : NSUInteger {
WK_PROTO_WKAO,
WK_PROTO_MOS
} WKProto;
// 设备类型
typedef enum : NSInteger {
WKDeviceFlagEnumUnknown = -1, // 未知
WKDeviceFlagEnumAPP = 0, // APP
WKDeviceFlagEnumWeb = 1, // Web
WKDeviceFlagEnumPC = 2 // PC
} WKDeviceFlagEnum;
typedef enum : NSUInteger {
WKPullModeDown,
WKPullModeUp,
} WKPullMode;
// cmd sign签名错误
#define WKCMDSignError @"cmdSignError"
// 排序序号因子
#define WKOrderSeqFactor 1000

View File

@ -0,0 +1,90 @@
//
// WKConversation.h
// WuKongIMSDK
//
// Created by tt on 2019/12/8.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
#import "WKChannelInfo.h"
#import "WKMessage.h"
#import "WKReminderManager.h"
#import "WKConversationExtra.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKConversation : NSObject<NSCopying>
@property(nonatomic,strong) WKChannel *channel; // 频道
@property(nonatomic,strong,nullable) WKChannel *parentChannel; // 父类频道
/**
* WKChannelManager fetchChannelInfo:completion
*/
@property(nullable,nonatomic,strong,readonly) WKChannelInfo *channelInfo;
/**
*/
@property(nonatomic,copy) NSString *avatar;
/**
seq
*/
//@property(nonatomic,assign) uint32_t lastClientSeq;
/// 最后一条消息的客户端编号
@property(nonatomic,copy) NSString *lastClientMsgNo;
// 最后一条消息的额messageSeq
@property(nonatomic,assign) uint32_t lastMessageSeq;
/**
*/
@property(nonatomic,strong) WKMessage *lastMessage;
/**
*/
@property(nonatomic,strong) WKMessage *lastMessageInner;
/**
10
*/
@property(nonatomic,assign) NSInteger lastMsgTimestamp;
//@property(nonatomic,assign) uint32_t browseTo;
/**
*/
@property(nonatomic,assign) NSInteger unreadCount;
/**
*/
@property(nonatomic,strong) NSArray<WKReminder*> *reminders;
@property(nonatomic,strong,readonly) NSArray<WKReminder*> *simpleReminders; // 除去重复的type了的reminder
/**
*/
@property(nonatomic,strong) NSDictionary *extra;
/// 数据版本
@property(nonatomic,assign) long long version;
// 是否已删除
@property(nonatomic,assign) NSInteger isDeleted;
// 免打扰
@property(nonatomic,assign) BOOL mute;
// 置顶
@property(nonatomic,assign) BOOL stick;
/// 重新加载最后一条消息(重新从数据库里获取)
-(void) reloadLastMessage;
// 服务端扩展数据
@property(nonatomic,strong) WKConversationExtra *remoteExtra;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,211 @@
//
// WKConversationDB.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
#import <Foundation/Foundation.h>
#import "WKConversation.h"
#import "WKDB.h"
NS_ASSUME_NONNULL_BEGIN
@class WKConversationAddOrUpdateResult;
@interface WKConversationDB : NSObject
+ (WKConversationDB *)shared;
/**
@param conversation <#conversation description#>
*/
-(void) addOrUpdateConversation:(WKConversation*)conversation;
/// 取代最近会话
/// @param conversations <#conversation description#>
-(void) replaceConversations:(NSArray<WKConversation*>*)conversations;
/// 添加最近会话信息
/// @param conversation <#conversation description#>
-(void) addConversation:(WKConversation*)conversation;
/// 恢复指定会话
/// @param channel <#channel description#>
/// @return 如果存在会话的会话则返回不存在则返回nil
-(WKConversation*) recoveryConversation:(WKChannel*)channel;
/**
@param channel <#channel description#>
@param db <#db description#>
@return <#return value description#>
*/
-(WKConversation*) getConversationWithChannel:(WKChannel*)channel db:(FMDatabase*)db;
/// 查询指定频道的最近会话包含is_deleted=1的频道
/// @param channel 指定频道
/// @param db <#db description#>
-(WKConversation*) getConversationWithChannelInAll:(WKChannel*)channel db:(FMDatabase*)db;
/**
@return <#return value description#>
*/
-(NSArray<WKConversation*>*) getConversationList;
/**
@param channel
@return <#return value description#>
*/
-(WKConversation*) getConversation:(WKChannel*)channel;
// 通过频道集合获取最近会话集合
-(NSArray<WKConversation*>*) getConversations:(NSArray<WKChannel*> *)channels;
/**
@param lastClientMsgNo
@return <#return value description#>
*/
-(WKConversation*) getConversationWithLastClientMsgNo:(NSString*)lastClientMsgNo;
/// 获取会话最大数据版本号
-(long long) getConversationMaxVersion;
/// 获取同步key
-(NSString*) getConversationSyncKey;
/**
@param conversation <#conversation description#>
*/
-(void) updateConversation:(WKConversation*)conversation;
/**
@param conversation <#conversation description#>
@param db <#db description#>
*/
-(void) updateConversation:(WKConversation*)conversation db:(FMDatabase*)db;
/**
@param conversation <#conversation description#>
@param db <#db description#>
*/
-(void) insertConversation:(WKConversation*)conversation db:(FMDatabase*)db;
/**
@param channel <#channel description#>
*/
-(void) clearConversationUnreadCount:(WKChannel*)channel;
/// 设置最近会话未读数
/// @param channel 频道
/// @param unread 未读数量
-(void) setConversationUnreadCount:(WKChannel*)channel unread:(NSInteger)unread;
/// 删除指定频道的最近会话
/// @param channel 频道对象
-(void) deleteConversation:(WKChannel*)channel;
/// 删除所有最近会话
-(void) deleteAllConversation;
/**
@param channel <#channel description#>
@param title <#title description#>
@param avatar <#avatar description#>
@param db <#db description#>
*/
-(void) updateConversation:(WKChannel*)channel title:(NSString*)title avatar:(NSString*) avatar db:(FMDatabase*)db;
//
///**
// 追加提醒
//
// @param reminder 提醒项
// @param channel 频道
// @return 追加后的z最近会话
// */
//-(WKConversation*) appendReminder:(WKReminder*) reminder channel:(WKChannel*)channel;
//
//
///**
// 移除某种类型的提醒
//
// @param type <#type description#>
// @param channel <#channel description#>
// @return <#return value description#>
// */
//-(WKConversation*) removeReminder:(WKReminderType)type channel:(WKChannel*)channel;
//
///**
//清除指定频道的所有提醒
//
// @param channel 频道
// @return <#return value description#>
// */
//-(WKConversation*) clearAllReminder:(WKChannel*)channel;
//
//
///**
// 清除指定频道指定类型的提醒
//
// @param channel 频道
// @param type 提醒类型
// @return <#return value description#>
// */
//-(WKConversation*) clearReminder:(WKChannel*)channel type:(NSInteger)type;
//
/**
*/
-(NSInteger) getAllConversationUnreadCount;
/// 更新频道预览的位置
/// @param browseTo <#browseTo description#>
/// @param channel <#channel description#>
-(void) updateBrowseTo:(uint32_t)browseTo forChannel:(WKChannel*)channel;
@end
// 最近会话添加或修改结果
@interface WKConversationAddOrUpdateResult : NSObject
@property(nonatomic,assign) BOOL insert;
@property(nonatomic,assign) BOOL modify; // 数据是否修改添加或更新都为true
@property(nonatomic,strong) WKConversation *conversation;
+(instancetype) initWithInsert:(BOOL)insert modify:(BOOL)modify conversation:(WKConversation*)conversation;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,23 @@
//
// WKConversationExtra.h
// WuKongIMSDK
//
// Created by tt on 2022/4/23.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKConversationExtra : NSObject
@property (nonatomic, strong) WKChannel *channel;
//@property (nonatomic, assign) uint32_t browseTo; // 预览位置 预览到的位置,与会话保持位置不同的是 预览到的位置是用户读到的最大的messageSeq。跟未读消息数量有关系
@property (nonatomic, assign) uint32_t keepMessageSeq; // 保持的位置的messageSeq
@property (nonatomic, assign) NSInteger keepOffsetY; // 保持的位置Y的偏移量
@property (nonatomic, copy) NSString *draft; // 草稿
@property (nonatomic, assign) int64_t version; // 数据版本
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
//
// WKConversationExtraDB.h
// WuKongIMSDK
//
// Created by tt on 2022/4/23.
//
#import <Foundation/Foundation.h>
#import "WKConversationExtra.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKConversationExtraDB : NSObject
+ (WKConversationExtraDB *)shared;
-(void) addOrUpdates:(NSArray<WKConversationExtra*>*)extras;
-(void) updateVersion:(WKChannel*)channel version:(int64_t)version;
-(int64_t) getMaxVersion;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,24 @@
//
// WKConversationLastMessageAndUnreadCount.h
// WuKongIMSDK
//
// Created by tt on 2022/5/27.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
// 会话最后一条消息和需要累加的未读数量
@interface WKConversationLastMessageAndUnreadCount : NSObject
// 最后一条消息
@property(nonatomic,strong) WKMessage *lastMessage;
// 需要累加的未读数量
@property(nonatomic,assign) NSInteger incUnreadCount;
// 提醒项
//@property(nonatomic,strong) WKReminderManager *reminderManager;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,167 @@
//
// WKConversationManager.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
#import "WKConversation.h"
#import "WKConversationDB.h"
#import "WKSyncConversationModel.h"
#import "WKConversationExtra.h"
@protocol WKConversationManagerDelegate;
NS_ASSUME_NONNULL_BEGIN
typedef void(^WKSyncConversationCallback)(WKSyncConversationWrapModel* __nullable model,NSError * __nullable error);
typedef void(^WKSyncConversationAck)(uint64_t cmdVersion,void(^ _Nullable complete)(NSError * _Nullable error));
// 同步会话返回 timestamp最新会话的时间戳 lastMsgSeqs客户端所有会话的最后一条消息序列号 格式: channelID:channelType:last_msg_seq|channelID:channelType:last_msg_seq
typedef void (^WKSyncConversationProvider)(long long version,NSString *lastMsgSeqs,WKSyncConversationCallback callback);
// 同步最近会话扩展
typedef void(^WKSyncConversationExtraCallback)(NSArray<WKConversationExtra*>* __nullable extras,NSError * __nullable error);
typedef void (^WKSyncConversationExtraProvider)(long long version,WKSyncConversationExtraCallback callback);
// 更新扩展
typedef void (^WKUpdateConversationExtraCallback)(int64_t version,NSError * __nullable error);
typedef void (^WKUpdateConversationExtraProvider)(WKConversationExtra *extra,WKUpdateConversationExtraCallback callback);
@interface WKConversationManager : NSObject
/**
@return
*/
-(NSArray<WKConversation*>*) getConversationList;
/// 添加最近会话信息
/// @param conversation <#conversation description#>
-(void) addConversation:(WKConversation*)conversation;
/**
@param channel <#channel description#>
*/
-(void) clearConversationUnreadCount:(WKChannel*)channel;
/// 设置未读数
/// @param channel 频道
/// @param unread 未读数量
-(void) setConversationUnreadCount:(WKChannel*)channel unread:(NSInteger)unread;
/// 恢复指定频道的会话
/// @param channel <#channel description#>
-(void) recoveryConversation:(WKChannel*)channel;
// 更新或添加扩展
-(void) updateOrAddExtra:(WKConversationExtra*)extra;
// 同步最近会话扩展
-(void) syncExtra;
/// 删除最近会话
/// @param channel 频道
-(void) deleteConversation:(WKChannel*)channel;
/// 获取指定频道的最近会话信息
/// @param channel <#channel description#>
-(WKConversation*) getConversation:(WKChannel*)channel;
-(NSArray<WKConversation*>*) getConversations:(NSArray<WKChannel*>*)channels;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKConversationManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKConversationManagerDelegate>) delegate;
/**
*/
-(NSInteger) getAllConversationUnreadCount;
/**
@param conversation <#conversation description#>
*/
- (void)callOnConversationUpdateDelegate:(WKConversation*)conversation;
/// 设置同步会话提供者
/// @param syncConversationProvider <#syncConversationProvider description#>
/// @param syncConversationAck <#syncConversationAck description#>
-(void) setSyncConversationProviderAndAck:(WKSyncConversationProvider) syncConversationProvider ack:(WKSyncConversationAck)syncConversationAck;
/// 同步最近会话
@property(nonatomic,copy,readonly) WKSyncConversationProvider syncConversationProvider;
@property(nonatomic,copy,readonly) WKSyncConversationAck syncConversationAck;
// 同步扩展提供者
@property(nonatomic,copy) WKSyncConversationExtraProvider syncConversationExtraProvider;
// 更新扩展提供者
@property(nonatomic,copy) WKUpdateConversationExtraProvider updateConversationExtraProvider;
@end
@protocol WKConversationManagerDelegate <NSObject>
@optional
/**
*/
- (void)onConversationUpdate:(NSArray<WKConversation*>*)conversations;
/**
@param channel
@param unreadCount
*/
- (void)onConversationUnreadCountUpdate:(WKChannel*)channel unreadCount:(NSInteger)unreadCount;
/// 最近会话被删除
/// @param channel <#channel description#>
-(void) onConversationDelete:(WKChannel*)channel;
/// 所有最近会话删除
-(void) onConversationAllDelete;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,49 @@
//
// WKConversationManagerInner.h
// Pods
//
// Created by tt on 2022/5/27.
//
#ifndef WKConversationManagerInner_h
#define WKConversationManagerInner_h
#endif /* WKConversationManagerInner_h */
@interface WKConversationManager ()
/**
@param conversation conversation
@param incUnreadCount
*/
-(WKConversationAddOrUpdateResult*) addOrUpdateConversation:(WKConversation*)conversation incUnreadCount:(NSInteger)incUnreadCount;
-(WKConversationAddOrUpdateResult*) addOrUpdateConversation:(WKConversation*)cs;
/// 处理同步下来的最近会话
/// @param model 会话同步对象
-(void) handleSyncConversation:(WKSyncConversationWrapModel*)model;
/**
@param conversations
*/
- (void)callOnConversationUpdateDelegates:(NSArray<WKConversation*>*)conversations;
/// 调用删除所有最近会话委托
- (void)callOnConversationAllDeleteDelegate;
@end

View File

@ -0,0 +1,17 @@
//
// WKConversationUtil.h
// WuKongIMSDK
//
// Created by tt on 2020/1/24.
//
#import <Foundation/Foundation.h>
#import "WKConversation.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKConversationUtil : NSObject
// 合并提醒数据
+(NSArray<WKReminder*>*) mergeReminders:(NSArray<WKReminder*>*)source dest:(NSArray<WKReminder*>*)dest;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,39 @@
//
// WKDB.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import <fmdb/FMDB.h>
#import "WKFMDatabaseQueue.h"
//消息表
#define TB_MESSAGE @"message"
NS_ASSUME_NONNULL_BEGIN
@interface WKDB : NSObject
@property (nonatomic, strong) WKFMDatabaseQueue *dbQueue;
+ (WKDB *)sharedDB;
/**
@param uid uid
*/
-(void) switchDB:(NSString*)uid;
/**
@param uid <#uid description#>
@return <#return value description#>
*/
-(BOOL) needSwitchDB:(NSString*)uid;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,294 @@
//
// WKDBMigrationManager.h
// WKDBMigrationManager
//
// Created by Blake Watters on 6/4/14.
// Copyright (c) 2014 Layer Inc. All rights reserved.
//
// 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.
//
#import <fmdb/FMDatabase.h>
#import <fmdb/FMDatabaseQueue.h>
@protocol WKDBMigrating;
/**
@abstract The `WKDBMigrationManager` class provides a simple, flexible interface for managing migrations for
a SQLite database that is accessed via FMDB.
*/
@interface WKDBMigrationManager : NSObject
///-----------------------------------
/// @name Creating a Migration Manager
///-----------------------------------
/**
@abstract Creates a new migration manager with a given database and migrations bundle.
@param database The database with which to initialize the migration manager.
@return A new migration manager.
*/
+ (instancetype)managerWithDatabase:(FMDatabase *)database;
/**
@abstract Creates a new migration manager with a database for the given database and migrations bundle.
@param path The path to a database with which to initialize the migration manager.
@return A new migration manager.
*/
+ (instancetype)managerWithDatabaseAtPath:(NSString *)path;
/**
@abstract Determines whether the receiver will perform a search for dynamically defined migrations. Default: `YES`.
@discussion When `YES` all classes will be enumerated to search for any that conform to the `WKDBMigrating` protocol.
*/
@property (nonatomic, assign) BOOL dynamicMigrationsEnabled;
///--------------------------------------------------
/// @name Accessing Database Path & Migrations Bundle
///--------------------------------------------------
/**
@abstract Returns the database of the receiver.
*/
@property (nonatomic, readonly) FMDatabase *database;
/**
@abstract Returns the migrations bundle for the receiver.
*/
@property (nonatomic, readonly) NSBundle *migrationsBundle;
///-----------------------------
/// @name Accessing Version Info
///-----------------------------
/**
@abstract Returns the current version of the database managed by the receiver or `0` if the
migrations table is not present.
*/
@property (nonatomic, readonly) uint64_t currentVersion;
/**
@abstract Returns the origin version of the database managed by the receiver or `0` if the
migrations table is not present.
*/
@property (nonatomic, readonly) uint64_t originVersion;
///---------------------------
/// @name Accessing Migrations
///---------------------------
/**
@abstract Returns all migrations discovered by the receiver. Each object returned conforms to the `WKDBMigrating` protocol. The
array is returned in ascending order by version.
@discussion The manager discovers migrations by analyzing all files that end in a .sql extension in the `migrationsBundle`
and accumulating all classes that conform to the `WKDBMigrating` protocol. These migrations can then be sorted and applied
to the target database.
@note The list of migrations is memoized for efficiency.
*/
@property (nonatomic, readonly) NSArray *migrations;
/**
@abstract Returns the version numbers of the subset of `migrations` that have already been applied to the database
managed by the receiver in ascending order.
*/
@property (nonatomic, readonly) NSArray *appliedVersions;
/**
@abstract Returns the version numbers of the subset of `migrations` that have not yet been applied to the database
managed by the receiver in ascending order.
*/
@property (nonatomic, readonly) NSArray *pendingVersions;
/**
@abstract Returns a migration object with a given version number or `nil` if none could be found.
@param version The version of the desired migration.
@return A migration with the specified version or `nil` if none could be found.
*/
- (id<WKDBMigrating>)migrationForVersion:(uint64_t)version;
/**
@abstract Returns a migration object with a given name or `nil` if none could be found.
@param name The name of the desired migration.
@return A migration with the specified named or `nil` if none could be found.
*/
- (id<WKDBMigrating>)migrationForName:(NSString *)name;
///-------------------------
/// @name Adding a Migration
///-------------------------
/**
@abstract Adds a migration to the receiver's list.
@discussion This method can be used to append code based migrations to the set if you do not wish to use dynamic migration discovery. If
the migration last has been previously computed, adding a migration will recompute the list.
@param migration The migration to add.
*/
- (void)addMigration:(id<WKDBMigrating>)migration;
/**
@abstract Adds migrations from the array to the receiver's list.
@discussion This method can be used to append code based migrations to the set if you do not wish to use dynamic migration discovery. If
the migration last has been previously computed, adding migrations will recompute the list.
@param migrations An array of objects conforming to `WKDBMigrating` protocol.
*/
- (void)addMigrations:(NSArray *)migrations;
///------------------------------------
/// @name Managing the Migrations Table
///------------------------------------
/**
@abstract Returns a Boolean value that indicates if the `schema_migrations` table
is present in the database.
*/
@property (nonatomic, readonly) BOOL hasMigrationsTable;
/**
@abstract Creates the `schema_migrations` table used by `WKDBMigrationManager` to maintain an index of applied migrations.
@param error A pointer to an error object that is set upon failure to create the migrations table.
@return A Boolean value that indicates if the creation of the migrations table was successful.
*/
- (BOOL)createMigrationsTable:(NSError **)error;
///--------------------------
/// @name Migrating Databases
///--------------------------
/**
@abstract Returns a Boolean value that indicates if the database managed by the receiver is in need of migration.
*/
@property (nonatomic, readonly) BOOL needsMigration;
/**
@abstract Migrates the database managed by the receiver to the specified version, optionally providing progress via a block.
@discussion Migration is performed within a transaction that is rolled back if any errors occur during migration.
@param version The target version to migrate the database to. Pass `UINT64_MAX` to migrate to the latest version.
@param progressBlock An optional block to be invoked each time a migration is applied. The block has no return value and accepts a single `NSProgress` argument. The
progress object can be used to cancel a migration in progress.
@param error A pointer to an error object that is set upon failure to complete the migrations.
@return `YES` if migration was successful, else `NO`.
*/
- (BOOL)migrateDatabaseToVersion:(uint64_t)version bundle:(NSBundle*)migrationsBundle progress:(void (^)(NSProgress *progress))progressBlock error:(NSError **)error;
- (BOOL)migrateDatabase:(NSBundle*)migrationsBundle error:(NSError **)error;
@end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
@abstract The `WKDBMigrating` protocol is adopted by classes that wish to provide migration of SQLite databases accessed via FMDB. The
`WKDBMigrationManager` project ships with a single concrete implementation in the `FMDBFileMigration` class. Non file backed
migrations can be implemented by conforming to the `WKDBMigrating` protocol.
*/
@protocol WKDBMigrating <NSObject>
///-------------------------------------
/// @name Accessing Migration Properties
///-------------------------------------
/**
@abstract The name of the migration.
*/
@property (nonatomic, readonly) NSString *name;
/**
@abstract The numeric version of the migration.
@discussion While monotonically incremented versions are fully supported, it is recommended that to use a timestamp format such as
201406063106474. Timestamps avoid unnecessary churn in a codebase that is heavily branched.
*/
@property (nonatomic, readonly) uint64_t version;
///--------------------------
/// @name Migrating Databases
///--------------------------
/**
@abstract Tells the receiver to apply its changes to the given database and return a Boolean value indicating success or failure.
@discussion The `WKDBMigrationManager` manages a transaction while migrations are being applied. Should any call to `migrateDatabase:error` return `NO`,
then the transaction is rolled back.
@param database The database on which to apply the migration.
@param error A pointer to an error object to set should the transaction fail.
@return A Boolean value indicating if the
*/
- (BOOL)migrateDatabase:(FMDatabase *)database error:(out NSError *__autoreleasing *)error;
@end
/**
@abstract The `FMDBFileMigration` class provides a concrete implementation of the `WKDBMigrating` protocol that models
a migration stored on disk a SQL file. The filename encodes the name and version of the migration. Conformant filenames are
of the form `[version]_[name].sql`.
*/
@interface WKDBFileMigration : NSObject <WKDBMigrating>
///--------------------------------
/// @name Creating a File Migration
///--------------------------------
/**
@abstract Creates and returns a new migration with the file at the given path.
@discussion Conformance of filenames can be evaluated with the `FMDBIsMigrationAtPath` utility function.
@param path The path to a file containing a SQL migration with a conformant filename.
*/
+ (instancetype)migrationWithPath:(NSString *)path;
/**
@abstract The path to the SQL migration file on disk.
*/
@property (nonatomic, readonly) NSString *path;
/**
@abstract A convenience accessor for retrieving the SQL from the receiver's path.
*/
@property (nonatomic, readonly) NSString *SQL;
@end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
@abstract The domain for errors created by `WKDBMigrationManager`.
*/
extern NSString *const WKDBMigrationManagerErrorDomain;
/**
@abstract A key for an `NSNumber` object in the `userInfo` of an `NSProgress` object specifying the version
that the database was just migrated to.
@see `migrateDatabase:error:`
*/
extern NSString *const WKDBMigrationManagerProgressVersionUserInfoKey;
/**
@abstract A key for an `id<WKDBMigrating>` object in the `userInfo` of an `NSProgress` object that identifies
the migration that was just applied to the database.
@see `migrateDatabase:error:`
*/
extern NSString *const WKDBMigrationManagerProgressMigrationUserInfoKey;
/**
@abstract Enumerates the errors returned by WKDBMigrationManager
*/
typedef NS_ENUM(NSUInteger, WKDBMigrationManagerError) {
/// Indicates that migration was halted due to cancellation
WKDBMigrationManagerErrorMigrationCancelled = 1
};
/**
@abstract Returns a Boolean value that indicates if the file at the given path is an FMDB Migration.
@discussion This function evaluates the last path component of the input string against the regular expression `/\d{1,15}_.+sql$/`.
@param path The path to inspect.
@return `YES` if the path could be identified as a migration, else `NO`.
*/
BOOL FMDBIsMigrationAtPath(NSString *path);

View File

@ -0,0 +1,71 @@
//
// WKData.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKDataWrite : NSObject
/// 初始化(大端模式)
+(instancetype) initLittleEndian;
-(void) writeUint8:(uint8_t)v;
-(void) writeUint16:(uint16_t)v;
-(void) writeUint32:(uint32_t)v;
-(void) writeUint64:(uint64_t)v;
/// 写可变字符串 前2位为字符串长度
/// @param v <#v description#>
-(void) writeVariableString:(NSString*)v;
-(void) writeData:(NSData*) data;
-(NSData*) toData;
@end
@interface WKDataRead : NSObject
-(instancetype) initWithData:(NSData*) data;
-(instancetype) initWithData:(NSData*) data littleEndian:(BOOL)littleEndian;
-(uint8_t) readUint8;
-(uint16_t) readUint16;
-(uint32_t) readUint32;
-(uint64_t) readUint64;
-(int64_t) readint64;
/// 读取指定长度的data
/// @param len <#len description#>
-(NSData*) readData:(int)len;
-(NSString*) readString;
-(uint32_t) readLenth;
// 字节里是否包含完整的长度
-(BOOL) lengthFull;
// 长度的长度
-(int) lenthLength;
-(NSData*) remainingData;
+(void) numberHNMemcpy:(void*)dest src:(const void *)src count:(unsigned int)count;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,22 @@
//
// WKDisconnectPacket.h
// WuKongIMSDK
//
// Created by tt on 2020/1/30.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKDisconnectPacket : WKPacket<WKPacketBodyCoder>
// 原因代码
@property(nonatomic,assign) uint8_t reasonCode;
// 原因字符串
@property(nonatomic,copy) NSString *reason;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,26 @@
//
// WKFMDatabaseQueue.h
// WuKongIMSDK
//
// Created by tt on 2021/8/26.
//
#import <fmdb/FMDB.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKFMDatabaseQueue : NSObject
+(WKFMDatabaseQueue*) databaseQueue:(FMDatabaseQueue*)queue;
- (void)inDatabase:(void (NS_NOESCAPE^)(FMDatabase * _Nonnull db))block;
- (void)inTransaction:(__attribute__((noescape)) void (^)(FMDatabase *db, BOOL *rollback))block;
-(void) close;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,42 @@
//
// WKFileUtil.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKFileUtil : NSObject
+(BOOL)copyFileFromPath:(NSString *)fromPath toPath:(NSString *)toPath;
+ (BOOL)moveFileFromPath:(NSString *)fromPath toPath:(NSString *)toPath;
+ (BOOL)fileIsExistOfPath:(NSString *)filePath;
/**
@param dirPath
@return <#return value description#>
*/
+(BOOL)createDirectoryIfNotExist:(NSString *)dirPath;
/**
@param filePath
@return <#return value description#>
*/
+ (BOOL)creatFileIfNotExist:(NSString *)filePath;
+ (BOOL)removeFileOfPath:(NSString *)filePath;
+ (BOOL)removeFileOfURL:(NSURL *)fileURL;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// WKViewedManager.h
// WuKongIMSDK
//
// Created by tt on 2022/8/17.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKFlameManager : NSObject
+ (WKFlameManager *)shared;
/**
*/
-(void) didViewed:(NSArray<WKMessage*>*) messages;
/**
*/
-(NSArray<WKMessage*>*) getMessagesOfNeedFlame;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,30 @@
//
// WKHeader.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKHeader : NSObject
// 剩余长度
@property(nonatomic,assign) uint32_t remainLength;
// 包类型
@property(nonatomic,assign) uint8_t packetType;
// 是否显示未读
@property(nonatomic,assign) BOOL showUnread; // RedDot
// 是否不存储
@property(nonatomic,assign) BOOL noPersist;
// 是否同步一次
@property(nonatomic,assign) BOOL syncOnce;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,73 @@
//
// WKImageMessageContent.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
// 图片消息content
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "WKMediaMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKImageContent : WKMediaMessageContent
@property(nonatomic,assign) CGFloat width; // 图片宽度
@property(nonatomic,assign) CGFloat height; // 图片高度
/*!
@param image
@return
*/
+ (instancetype)initWithImage:(UIImage *)image;
/// 通过data初始化
/// @param data 图片数据
/// @param width 图片宽度
/// @param height 图片高度
+ (instancetype)initWithData:(NSData *)data width:(CGFloat)width height:(CGFloat)height;
/// 初始化
/// @param data 原图data
/// @param width 原图宽度
/// @param height 原图高度
/// @param thumbData 缩略图data 如果传了缩略图的data数据sdk将不再生成缩略图数据
+ (instancetype)initWithData:(NSData *)data width:(CGFloat)width height:(CGFloat)height thumbData:( nullable NSData*)thumbData;
/*!
@discussion NO
*/
@property (nonatomic, getter=isFull) BOOL full;
/*!
*/
@property (nonatomic, strong,nullable) UIImage *thumbnailImage;
@property (nonatomic, strong,readonly) NSData *thumbnailData;
/*!
*/
@property (nonatomic, strong,readonly) UIImage *originalImage;
/*!
*/
@property (nonatomic, strong, readonly) NSData *originalImageData;
-(void) releaseData;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// WKMOSContentConvertManager.h
// WuKongIMSDK
//
// Created by tt on 2020/6/5.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMOSContentConvertManager : NSObject
+ (WKMOSContentConvertManager *)shared;
// 将mos的content转换为lm的contentTODO:为了兼容lm协议如果没有指定mos协议不用管此方法
-(NSDictionary*) convertContentToLM:(NSDictionary *)contentDic message:(WKMessage*)message;
// 将lm的content转换为mos的content TODO:为了兼容lm协议如果没有指定mos协议不用管此方法
-(NSDictionary*) convertContentToMOS:(NSDictionary *)contentDic message:(WKMessage*)message;
/// 将mos正文类型转换为lm的正文类型
/// @param mosContentType <#mosContentType description#>
-(NSInteger) convertTypeToLM:(NSInteger)mosContentType;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,188 @@
//
// WKMediaManager.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
//
#import <Foundation/Foundation.h>
#import "WKMediaProto.h"
#import "WKMessage.h"
#import "WKTaskProto.h"
#import "WKTaskManager.h"
#import <CoreGraphics/CGBase.h>
#import <AVFoundation/AVFoundation.h>
#import "WKMessageFileDownloadTask.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKMediaUploadStateProcessing = 0,
WKMediaUploadStateSuccess = 1,
WKMediaUploadStateFail = 2,
} WKMediaUploadState;
typedef enum : NSUInteger {
WKMediaDownloadStateProcessing = 0,
WKMediaDownloadStateSuccess = 1,
WKMediaDownloadStateFail = 2,
} WKMediaDownloadState;
@interface WKFileInfo : NSObject
@property(nonatomic,copy) NSString *fid; // 文件唯一id
@property(nonatomic,copy) NSString *name; // 文件名
@property(nonatomic,assign) long size; // 文件大小单位byte
@property(nonatomic,copy) NSString *url; // 文件路径
@end
/**
*/
@protocol WKMediaManagerDelegate <NSObject>
/**
@param media
*/
-(void) mediaManageUpdate:(id<WKMediaProto>)media;
@end
/**
*/
typedef id<WKTaskProto>_Nonnull(^WKMediaUploadTaskProvider)(WKMessage* message);
/**
*/
typedef id<WKTaskProto>_Nonnull(^WKMediaDownloadTaskProvider)(WKMessage* message);
// 音频播放完成block
typedef void(^WKAudioPlayerDidFinishBlock)(AVAudioPlayer *player,BOOL successFlag);
// 音频播放进度
typedef void (^WKAudioPlayerDidProgressBlock)(AVAudioPlayer *player);
@interface WKMediaManager : NSObject
+ (WKMediaManager *)shared;
@property(nonatomic,strong) WKTaskManager *taskManager;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKMediaManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKMediaManagerDelegate>) delegate;
/**
*/
@property(nonatomic,copy) WKMediaDownloadTaskProvider downloadTaskProvider;
/**
*/
@property(nonatomic,copy) WKMediaUploadTaskProvider uploadTaskProvider;
/**
@param message
*/
-(void) upload:(WKMessage*) message;
/**
@param message <#message description#>
*/
-(WKMessageFileDownloadTask*) download:(WKMessage*)message;
/**
@param message
@param callback
*/
-(WKMessageFileDownloadTask*) download:(WKMessage*)message callback:(void(^ __nullable)(WKMediaDownloadState state,CGFloat progress,NSError * __nullable error))callback;
///**
// 获取上传进度
//
// @param message 消息
// @return <#return value description#>
// */
//-(CGFloat) getUploadProgress:(WKMessage*)message;
//
//
///**
// 获取下载进度
//
// @param message 消息
// @return <#return value description#>
// */
//-(CGFloat) getDowloadProgress:(WKMessage*)message;
/**
@param message <#message description#>
*/
-(void) voiceMessageThumbToSource:(WKMessage*)message;
/**
*
*
*/
- (BOOL)isAudioPlaying;
/**
*
*
* @param filePath
*/
-(void) playAudio:(NSString *)filePath playerDidFinish:(WKAudioPlayerDidFinishBlock)finishBlock progress:(WKAudioPlayerDidProgressBlock)progressBlock;
/**
*
*/
- (void)stopAudioPlay;
/**
*/
-(void) pauseAudioPlay;
/**
*/
-(void) continuePlay;
// 获取所有消息缓存大小
-(long long) messageCacheSize;
-(void) cleanMessageCache;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,18 @@
//
// WKMediaMessageContent.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
//
#import <Foundation/Foundation.h>
#import "WKMessageContent.h"
#import "WKMediaProto.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMediaMessageContent : WKMessageContent<WKMediaProto>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,63 @@
//
// WKMediaMessageContentProto.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
@protocol WKMediaProto <NSObject>
/**
*/
@property (nonatomic, weak) WKMessage *message; //TODO: 这里要注意不能声明为strong 如果声明为strong message和media互相引用 就释放不掉了导致内存爆炸。
/**
remoteUrl为空时此属性必须有值
*/
@property (nonatomic, copy) NSString *localPath;
/**
SDK会为该属性赋值
*/
@property (nonatomic, copy) NSString *remoteUrl;
/**
*/
@property(nullable,nonatomic,copy) NSString *extension;
/**
*/
@property(nullable,nonatomic,copy) NSString *thumbPath;
/**
*/
@property(nullable,nonatomic,copy) NSString *thumbExtension;
/**
NSData数据保存到localPath对应的位置
WKMediaMessageContent必须调用 [super writeDataToLocalPath]
*/
-(void) writeDataToLocalPath;
// 从本地扩展数据里获取值
-(nullable id) getExtra:(NSString*)key;
// 设置值到本地扩展字段内
-(void) setExtra:(id)value key:(NSString*)key;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,43 @@
//
// WKMediaUtils.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
//
#import <Foundation/Foundation.h>
#import "WKMediaProto.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMediaUtil : NSObject
/**
@param media <#media description#>
@return <#return value description#>
*/
+(NSString*) getLocalPath:(id<WKMediaProto>)media;
/**
@param media <#media description#>
@return <#return value description#>
*/
+(NSString*) getThumbLocalPath:(id<WKMediaProto>)media;
/**
@param channel <#channel description#>
@return <#return value description#>
*/
+(NSString*) getChannelDir:(WKChannel*) channel;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,39 @@
//
// WKCache.h
// WuKongIMBase
//
// Created by tt on 2020/1/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKMemoryCache : NSObject
/**
*/
@property(nonatomic,assign) NSInteger maxCacheNum;
/**
@param value
@param key
*/
-(void) setCache:(id __nullable)value forKey:(NSString*)key;
/**
@param key
@return
*/
-(id) getCache:(NSString*)key;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,104 @@
//
// WKMessage.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
#import "WKMessageContent.h"
#import "WKChannelInfo.h"
#import "WKConst.h"
#import "WKChannelMemberDB.h"
#import "WKTaskProto.h"
#import "WKSetting.h"
#import "WKMessageExtra.h"
#import "WKReaction.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMessageHeader : NSObject
// 是否红点
// 是否显示未读
@property(nonatomic,assign) BOOL showUnread; // RedDot
// 是否不存储
@property(nonatomic,assign) BOOL noPersist;
@property(nonatomic,assign) BOOL syncOnce; // 同步一次标记
@end
@interface WKMessage : NSObject
@property(nonatomic,strong) WKMessageHeader *header; // 消息头
@property(nonatomic,strong) WKSetting *setting; // 消息设置
@property(nonatomic,assign) uint32_t clientSeq; // 客户端序列号 (客户端提供,服务端原样返回)
@property(nonatomic,copy) NSString *clientMsgNo; /// 客户端消息唯一编号(相同clientMsgNo被认为是重复消息)
@property(nonatomic,assign) uint64_t messageId; // 消息ID全局唯一
@property(nonatomic,assign) uint32_t messageSeq; // 消息序列号(用户唯一,有序)
@property(nonatomic,assign) uint32_t orderSeq; // 消息排序号(消息越新序号越大)
@property(nonatomic,assign) NSInteger timestamp; // 消息时间(服务器时间,单位秒)
@property(nonatomic,assign) NSInteger localTimestamp; // 本地消息创建时间
@property(nonatomic,strong) WKChannelInfo *from; // 发送者
@property(nonatomic,copy) NSString *topic; // 消息话题
@property(nonatomic,copy) NSString *fromUid; // 发送者uid
@property(nonatomic,copy) NSString *toUid; // 接收者uid
@property(nonatomic,strong,readonly) WKChannelMember *memberOfFrom; // 发送者在频道里的成员信息
@property(nonatomic,strong) WKChannel *channel; // 频道
@property(nonatomic,strong) WKChannel *parentChannel; // 父类频道
@property(nullable,nonatomic,strong,readonly) WKChannelInfo *channelInfo; // 频道资料可能为空如果为空可以调用WKChannelManager fetchChannelInfo:completion 触发频道信息变更委托
@property(nonatomic,assign) NSInteger contentType; // 正文类型
@property(nonatomic,strong) WKMessageContent *content; // 消息正文
@property(nonatomic,strong) NSData *contentData; // 消息正文data数据
@property(nonatomic,assign) BOOL voiceReaded; // 语音是否已读 (对语音消息有效)
@property(nonatomic,assign) WKMessageStatus status; // 消息状态
@property(nonatomic,assign) WKReason reasonCode; // 原因代码,当status为WK_MESSAGE_FAIL时 应该有相应的原因代号
@property(nonatomic,weak,readonly) id<WKTaskProto> task; // 消息关联的任务(例如:下载图片任务,上传图片任务等等)
- (BOOL)isSend; // 是否是发送消息
@property(nonatomic,strong) NSMutableDictionary *extra; // 消息本地扩展数据
@property(nonatomic,strong,nullable) NSArray<WKReaction*> *reactions; // 消息回应集合
@property(nonatomic,assign) BOOL isDeleted; // 消息是否被删除
// ---------- 消息远程扩展 ----------
@property(nonatomic,assign) BOOL hasRemoteExtra; // 是否有远程消息扩展sdk内部用于插入消息扩展表的判断
@property(nonatomic,assign) BOOL viewed; // 是否已查看 0.未查看 1.已查看 (这个字段跟已读的区别在于是真正的查看了消息内容,比如图片消息 已读是列表滑动到图片消息位置就算已读viewed是表示点开图片才算已查看语音消息类似
@property(nonatomic,assign) NSInteger viewedAt; // 查看时间戳
@property(nonatomic,strong) WKMessageExtra *remoteExtra; // 消息远程扩展
//
//@property(nonatomic,assign) BOOL revoke; // 消息是否被撤回
//@property(nonatomic,copy) NSString *revoker; // 撤回者的uid
//@property(nonatomic,assign) NSInteger unreadCount; // 未读数量
//@property(nonatomic,assign) NSInteger readedCount; // 已读数量
//@property(nonatomic,assign) NSInteger extraVersion; // 扩展消息版本
//@property(nonatomic,assign) BOOL readed; // 消息是否已读(“我”是否已读)
//@property(nonatomic,strong,nullable) NSData *contentEditData; // 消息编辑后的正文data数据
//@property(nonatomic,strong,nullable) WKMessageContent *contentEdit; // 消息编辑后的正文
//@property(nonatomic,assign) NSInteger editedAt; // 消息编辑时间 0表示消息未被编辑
//@property(nonatomic,assign) BOOL isEdit; // 是否编辑
//@property(nonatomic,assign) BOOL needUpload; // 编辑内容是否需要上传
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,201 @@
//
// WKMessageContent.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
extern NSString * _Nonnull const WKEntityTypeRobotCommand; // robot命令
#import <Foundation/Foundation.h>
#import "WKUserInfo.h"
#import <fmdb/FMDB.h>
@class WKMessageContent;
NS_ASSUME_NONNULL_BEGIN
/*!
@
*/
typedef NS_ENUM(NSUInteger, WKMentionedType) {
/*!
@
*/
WK_Mentioned_All = 1,
/*!
@
*/
WK_Mentioned_Users = 2,
};
@interface WKMessageEntity : NSObject
@property(nonatomic,copy) NSString *type;
@property(nonatomic,assign) NSRange range;
@property(nonatomic,strong) id value;
+(WKMessageEntity*) type:(NSString*)type range:(NSRange)range;
+(WKMessageEntity*) type:(NSString*)type range:(NSRange)range value:(id _Nullable)value;
@end
/**
@
*/
@interface WKMentionedInfo : NSObject
/// 初始化@提醒信息
/// @param type <#type description#>
- (instancetype)initWithMentionedType:(WKMentionedType)type;
/*!
@
@param type @
@param uids @ID列表
@return @
*/
- (instancetype)initWithMentionedType:(WKMentionedType)type
uids:(NSArray *__nullable)uids;
/*!
@
*/
@property (nonatomic, assign) WKMentionedType type;
/*!
@ID列表
@discussion type是@nil
*/
@property (nonatomic, strong) NSArray<NSString *> *uids;
/*!
@
*/
@property (nonatomic, readonly) BOOL isMentionedMe;
@end
/// 回复
@interface WKReply : NSObject
@property(nonatomic,copy) NSString *messageID; // 被回复的消息ID
@property(nonatomic,assign) uint32_t messageSeq; // 被回复的消息seq
@property(nonatomic,copy) NSString *fromUID; // 被回复消息的发送者
@property(nonatomic,copy) NSString *fromName; // 被回复消息的发送者名称
@property(nonatomic,copy) NSString *rootMessageID; // 根消息ID可为空
@property(nonatomic,assign) BOOL revoke; // 是否被撤回
@property(nonatomic,strong) WKMessageContent *content; // 被回复的消息正文
@end
@class WKMessage;
@interface WKMessageContent : NSObject<NSCopying>
//TODO: 这里要注意不能声明为strong 如果声明为strong message和media互相引用 就释放不掉了导致内存爆炸。
@property(nonatomic,weak) WKMessage *message;
/**
*/
@property (nonatomic, strong) WKUserInfo *senderUserInfo;
/*!
@
*/
@property (nonatomic, strong) WKMentionedInfo *mentionedInfo;
/// 回复内容
@property(nonatomic,strong) WKReply *reply;
/*!
json数据
@discussion
json数据json数据将用于网络传输
*/
- (NSData *)encode;
// 上层无需实现encode 实现此方法即可
-(NSDictionary*) encodeWithJSON;
// 上层无序实现decode 实现此方法即可
-(void) decodeWithJSON:(NSDictionary*)contentDic;
/*!
json数据的内容反序列化
@param data json数据
@discussion
json数据
*/
- (void)decode:(NSData *)data;
// TODO: 解码消息只供DB使用为了兼容MOS的@消息,因为@消息有DB操作 如果直接调用DB会与外面的DB发生冲突
- (void)decode:(NSData *)data db:(FMDatabase*)db;
/**
@return
*/
+(NSInteger) contentType;
/// 实际获取到的contentType 这种情况只会一个content对象被指定多个contentType的时候可以通过这个属性获取到真实的contentType
@property(nonatomic,assign,readonly) NSInteger realContentType;
/*!
@return
@discussion
*/
- (NSString *)searchableWord;
/**
@return <#return value description#>
*/
- (NSString *)conversationDigest;
/// 消息正文字典
@property(nonatomic,strong) NSDictionary *contentDict;
/**
*/
@property(nonatomic,strong) NSMutableDictionary *extra;
/// in 如果此字段有值 表示 只有在此值内的uid才能看见此条消息
@property(nonatomic,strong) NSArray *visibles;
@property(nonatomic,copy,nullable) NSString *robotID; // 机器人编号如果是机器人发的消息需要给到机器人的ID
/// 消息entitiy项
@property(nonatomic,strong) NSArray<WKMessageEntity*> *entities;
@property(nonatomic,assign) BOOL flame; // 是否开启阅后即焚
@property(nonatomic,assign) NSInteger flameSecond; // 阅后即焚的秒数如果为0 表示读后就删,如果有值表示读后多少秒后删
// 用户滑动看见消息就认为已查看 默认为true
-(BOOL) viewedOfVisible;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,294 @@
//
// WKMessageDB.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
#import "WKSendackPacket.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMessageDB : NSObject
+ (WKMessageDB *)shared;
/**
@param messages
@return
*/
-(NSArray<WKMessage*>*) saveMessages:(NSArray<WKMessage*>*)messages;
/// 保存或更新消息
/// @param messages <#messages description#>
-(NSArray<WKMessage*>*) replaceMessages:(NSArray<WKMessage*>*)messages;
/**
@param channel
@param oldestOrderSeq
@param limit
@return
oldestOrderSeq为20count为2oldestOrderSeq为19和18的WKMessage对象列表
*/
//-(NSArray<WKMessage*>*) getMessages:(WKChannel*)channel oldestOrderSeq:(uint32_t)oldestOrderSeq limit:(int) limit;
//
/// 获取频道中,从指定消息之前、指定数量的最新消息实体
/// @param channel 查询指定频道
/// @param startOrderSeq 开始orderSeq
/// @param endOrderSeq 结束排序seq
/// @param limit 限制
/// @param pullMode 拉取模式
-(NSArray<WKMessage*>*) getMessages:(WKChannel*)channel startOrderSeq:(uint32_t)startOrderSeq endOrderSeq:(uint32_t)endOrderSeq limit:(int) limit pullMode:(WKPullMode)pullMode;
/// 获取消息列表
/// @param channel 频道对象
/// @param keyword 关键字
-(NSArray<WKMessage*>*) getMessages:(WKChannel*)channel keyword:(NSString*)keyword limit:(int) limit;
/// 获取消息
/// @param messageSeq 偏移的messageSeq
/// @param limit 数据限制
-(NSArray<WKMessage*>*) getMessages:(uint32_t)messageSeq limit:(int)limit;
-(NSArray<WKMessage*>*) getDeletedMessagesWithChannel:(WKChannel*)channel minMessageSeq:(uint32_t)minMessageSeq maxMessageSeq:(uint32_t)maxMessageSeq;
/// 获取消息序号区间内已经被删除的消息的messageSeq
/// @param channel 频道
/// @param minMessageSeq 最小消息序号
/// @param maxMessageSeq 最大消息序号
-(NSArray<NSNumber*>*) getDeletedMessageSeqWithChannel:(WKChannel*)channel minMessageSeq:(uint32_t)minMessageSeq maxMessageSeq:(uint32_t)maxMessageSeq;
/// 获取比messageSeq小并且已删除了的序号
/// @param channel 频道
/// @param messageSeq 消息序号
/// @param limit 最大数量
-(NSArray<NSNumber*>*) getDeletedLessThanMessageSeqWithChannel:(WKChannel*)channel messageSeq:(uint32_t)messageSeq limit:(int)limit;
/// 获取比messageSeq大并且已删除了的序号
/// @param channel 频道
/// @param messageSeq 消息序号
/// @param limit 最大数量
-(NSArray<NSNumber*>*) getDeletedMoreThanMessageSeqWithChannel:(WKChannel*)channel messageSeq:(uint32_t)messageSeq limit:(int)limit;
/**
@param clientSeqs <#clientSeqs description#>
@return <#return value description#>
*/
-(NSArray<WKMessage*>*) getMessagesWithClientSeqs:(NSArray<NSNumber*>*)clientSeqs;
/// 通过客户端消息编号获取消息列表
/// @param clientMsgNos <#clientMsgNos description#>
-(NSArray<WKMessage*>*) getMessagesWithClientMsgNos:(NSArray*)clientMsgNos;
/**
id集合获取消息
*/
-(NSArray<WKMessage*>*) getMessagesWithMessageIDs:(NSArray<NSNumber*>*)messageIDs;
/**
@param clientMsgNo
@return <#return value description#>
*/
-(WKMessage*) getMessageWithClientMsgNo:(NSString*)clientMsgNo;
/**
clientSeq的消息
@param clientSeq
@return <#return value description#>
*/
-(WKMessage*) getMessage:(uint32_t)clientSeq;
/// 通过消息序号查询消息
/// @param channel <#channel description#>
/// @param messageSeq <#messageSeq description#>
-(WKMessage*) getMessage:(WKChannel*)channel messageSeq:(uint32_t)messageSeq;
/// 通过排序号获取频道内指定消息
/// @param orderSeq <#orderSeq description#>
/// @param channel <#channel description#>
-(WKMessage*) getMessage:(WKChannel*)channel orderSeq:(uint32_t)orderSeq;
/// 获取小于指定orderSeq 有messageSeq的第一条消息
/// @param channel <#channel description#>
/// @param orderSeq <#orderSeq description#>
-(WKMessage*) getMessage:(WKChannel*)channel lessThanAndFirstMessageSeq:(uint32_t)orderSeq;
// 获取大于指定orderSeq 有messageSeq的第一条消息
-(WKMessage*) getMessage:(WKChannel*)channel moreThanAndFirstMessageSeq:(uint32_t)orderSeq;
/**
ID获取消息
@param messageId <#messageId description#>
@return <#return value description#>
*/
-(WKMessage*) getMessageWithMessageId:(uint64_t)messageId;
/**
@param sendackPackets <#sendackPackets description#>
*/
-(void) updateMessageWithSendackPackets:(NSArray<WKSendackPacket*> *)sendackPackets;
/**
@param content content内容
@param status
@param extra
@param clientSeq
*/
-(void) updateMessageContent:(NSData*)content status:(WKMessageStatus)status extra:(NSDictionary*)extra clientSeq:(uint32_t)clientSeq;
/**
@param voiceReaded
@param clientSeq ID
*/
-(void) updateMessageVoiceReaded:(BOOL)voiceReaded clientSeq:(uint32_t)clientSeq;
/**
@param extra <#extra description#>
@param clientSeq <#clientSeq description#>
*/
-(void) updateMessageExtra:(NSDictionary*) extra clientSeq:(uint32_t)clientSeq;
/**
*/
-(void) updateMessageUploadingToFailStatus;
/// 获取所有等待发送的消息
-(NSArray<WKMessage*>*) getMessagesWaitSend;
/**
@param status
@param clientSeq clientSeq
*/
-(void) updateMessageStatus:(WKMessageStatus)status withClientSeq:(uint32_t)clientSeq;
/// 更新消息撤回状态
/// @param revoke <#revoke description#>
/// @param clientMsgNo <#clientMsgNo description#>
-(void) updateMessageRevoke:(BOOL)revoke clientMsgNo:(NSString*)clientMsgNo;
/**
message_seq
@return <#return value description#>
*/
-(uint32_t) getMaxMessageSeq:(WKChannel*)channel;
/**
@param message
*/
-(void) deleteMessage:(WKMessage*)message;
/**
deleteMessage只是标记为删除
*/
- (void)destoryMessage:(WKMessage *)message;
/**
*/
-(NSArray<WKMessage*>*) getMessages:(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 <#channel description#>
@return <#return value description#>
*/
-(WKMessage*) getLastMessage:(WKChannel*)channel;
/// 获取指定偏移量的最新消息
/// @param channel <#channel description#>
/// @param offset <#offset description#>
-(WKMessage*) getLastMessage:(WKChannel*)channel offset:(NSInteger)offset;
/// 查询排序在指定message之前的消息数量
/// @param message <#message description#>
-(NSInteger) getOrderCountMoreThanMessage:(WKMessage*)message;
/**
*/
-(long long) getMessageExtraMaxVersion:(WKChannel*)channel;
/**
*/
-(NSArray<WKMessage*>*) getMessagesOfNeedFlame;
/**
ID
*/
-(long long) getMessageMaxID;
/// 更新消息为已查看
-(NSArray<WKMessage*>*) updateViewed:(NSArray<WKMessage*>*)messages;
/**
messageSeq的周围第一条消息的messageSeq 0
*/
-(uint32_t) getChannelAroundFirstMessageSeq:(WKChannel*)channel messageSeq:(uint32_t)messageSeq;
-(WKMessageContent*) decodeContent:(NSInteger)contentType data:(NSData *)contentData db:(FMDatabase*)db;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,41 @@
//
// WKMessageExtra.h
// WuKongIMSDK
//
// Created by tt on 2022/4/12.
//
#import <Foundation/Foundation.h>
#import "WKMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKContentEditUploadStatusSuccess, // 成功
WKContentEditUploadStatusWait, // 等待上传
WKContentEditUploadStatusError, // 上传错误
} WKContentEditUploadStatus; // 编辑正文上传状态
@interface WKMessageExtra : NSObject
@property(nonatomic,assign) uint64_t messageID; // 消息id
@property(nonatomic,copy) NSString *channelID; // 频道id
@property(nonatomic,assign) NSInteger channelType; // 频道类型
@property(nonatomic,assign) uint32_t messageSeq; // 消息id
@property(nonatomic,assign) BOOL readed; // 是否已读
@property(nonatomic,copy) NSDate *readedAt; // 已读时间
@property(nonatomic,assign) NSInteger readedCount; // 已读人数
@property(nonatomic,assign) NSInteger unreadCount; // 未读人数
@property(nonatomic,assign) BOOL revoke; // 是否撤回
@property(nonatomic,copy) NSString *revoker; // 撤回人的uid
@property(nonatomic,assign) int64_t extraVersion;
@property(nonatomic,strong,nullable) NSData *contentEditData; // 消息编辑后的正文data数据
@property(nonatomic,strong,nullable) WKMessageContent *contentEdit; // 消息编辑后的正文
@property(nonatomic,assign) NSInteger editedAt; // 消息编辑时间 0表示消息未被编辑
@property(nonatomic,assign) BOOL isEdit; // 是否编辑
@property(nonatomic,assign) WKContentEditUploadStatus uploadStatus; // 上传状态
@property(nonatomic,copy) NSDictionary *extra; // 扩展数据
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,42 @@
//
// WKMessageExtraDB.h
// WuKongIMSDK
//
// Created by tt on 2022/4/12.
//
#import <Foundation/Foundation.h>
#import "WKMessageExtra.h"
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMessageExtraDB : NSObject
+ (WKMessageExtraDB *)shared;
-(void) addOrUpdateMessageExtras:(NSArray<WKMessageExtra*>*)messageExtras;
-(void) addOrUpdateMessageExtra:(WKMessageExtra*)messageExtra db:(FMDatabase*)db;
-(long long) getMessageExtraMaxVersion:(WKChannel*)channel;
// 添加或更新正文编辑的内容
-(void) addOrUpdateContentEdit:(WKMessageExtra*)messageExtra;
// 通过消息ID获取消息扩展
-(WKMessageExtra*) getMessageExtraWithMessageID:(uint64_t)messageID;
// 获取等待上传的正文编辑内容
-(NSArray<WKMessageExtra*>*) getContentEditWaitUpload;
// 更新正文上传状态为失败
-(void) updateContentEditUploadStatusToFailStatus;
// 更新消息状态
-(void) updateUploadStatus:(WKContentEditUploadStatus)status withMessageID:(uint64_t)messageID;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
//
// WKMessageFileDownloadTask.h
// WuKongIMBase
//
// Created by tt on 2020/1/16.
//
#import <Foundation/Foundation.h>
#import "WKBaseTask.h"
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMessageFileDownloadTask : WKBaseTask
-(instancetype) initWithMessage:(WKMessage*)message;
// 消息
@property(nonatomic,strong) WKMessage *message;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
//
// WKMessageFileUploadTask.h
// WuKongIMSDK
//
// Created by tt on 2020/1/15.
//
#import <Foundation/Foundation.h>
#import "WKTaskProto.h"
#import "WKMessage.h"
#import "WKBaseTask.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMessageFileUploadTask : WKBaseTask
-(instancetype) initWithMessage:(WKMessage*)message;
// 消息
@property(nonatomic,strong) WKMessage *message;
/**
*/
@property(nullable,nonatomic,strong) NSString *remoteUrl;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,21 @@
//
// WKMessageStatusModel.h
// WuKongIMBase
//
// Created by tt on 2019/12/29.
//
#import <Foundation/Foundation.h>
#import "WKConst.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKMessageStatusModel : NSObject
// 消息唯一ID
@property(nonatomic,assign) uint32_t clientSeq;
// 消息状态
@property(nonatomic) WKMessageStatus status;
-(instancetype) initWithClientSeq:(uint32_t)clientSeq status:(WKMessageStatus)status;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,27 @@
//
// WKMultiMediaMessageContent.h
// WuKongIMSDK
//
// Created by tt on 2020/1/13.
//
#import <Foundation/Foundation.h>
#import "WKMessageContent.h"
#import "WKMediaProto.h"
NS_ASSUME_NONNULL_BEGIN
/**
使MessageContent
*/
@interface WKMultiMediaMessageContent : WKMessageContent
/**
*/
@property NSArray<id<WKMediaProto>> *medias;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,22 @@
//
// WKNOGeneraterUtil.h
// WuKongIMSDK
//
// Created by tt on 2020/6/1.
//
#import <Foundation/Foundation.h>
/**
* data创建唯一的64位数据签名
*
* @param[in] psrc src data
* @param[in] slen data的长度
* @return
* - 1
* - -1
* @note
* - if slen<0
* - if slen==0sign = 0:0
*/
uint64_t get_sign64 (const char* psrc, int slen);

View File

@ -0,0 +1,143 @@
//
// WKOptions.h
// CocoaAsyncSocket
//
// Created by tt on 2019/11/23.
//
#import <Foundation/Foundation.h>
#import "WKConnectInfo.h"
#import "WKConst.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKModeWrite, // 写扩散模式
WKModeRead, // 读扩散模式
} WKMode;
typedef WKConnectInfo*_Nonnull(^WKConnectInfoCallback)(void);
@interface WKOptions : NSObject
/**
IM的host
*/
@property(nonatomic,copy) NSString *host;
/**
IM的端口
*/
@property(nonatomic,assign) uint16_t port;
/// IM模式
@property(nonatomic,assign) WKMode mode;
/**
*/
@property(nonatomic,copy) WKConnectInfoCallback connectInfoCallback;
/**
*/
@property(nullable,nonatomic,strong) WKConnectInfo *connectInfo;
/**
debug模式
*/
@property(nonatomic,assign) bool isDebug;
/**
@return <#return value description#>
*/
-(BOOL) hasLogin;
/**
*/
@property(nonatomic,assign) NSTimeInterval heartbeatInterval;
/**
*/
@property(nonatomic,copy) NSString *dbDir;
/// db前缀
@property(nonatomic,copy) NSString *dbPrefix;
// 消息文件根目录
@property(nonatomic,copy) NSString *messageFileRootDir;
/**
*/
@property(nonatomic,assign) bool enableMessageAttachUserInfo;
/**
()
*/
@property(nonatomic,assign) NSTimeInterval messageRetryInterval;
// 编辑后的消息正文上传重试间隔 (单位秒)
@property(nonatomic,assign) NSTimeInterval contentEditRetryInterval;
// reminder已done的数据上传过期时间超过这个时间将设置为上传失败 (单位秒)
@property(nonatomic,assign) NSTimeInterval reminderDoneUploadExpire;
@property(nonatomic,assign) NSTimeInterval reminderRetryInterval; // 提醒项重试间隔
@property(nonatomic,assign) NSInteger reminderRetryCount; // 提醒项重试次数
/**
*/
@property(nonatomic,assign) NSInteger messageRetryCount;
// 消息正文重试次数
@property(nonatomic,assign) NSInteger contentEditRetryCount;
/**
flush到服务器的间隔
*/
@property(nonatomic,assign) NSTimeInterval receiptFlushInterval;
/**
线
*/
@property(nonatomic,assign) NSInteger offlineMessageLimit;
/// 发送图片的时候图片最大大小,大于这个大小将自动压缩
@property(nonatomic,assign) long imageMaxBytes;
/// SDK使用消息协议版本默认使用最新的协议如果使用旧协议需要手动设置值
@property(nonatomic,assign) uint8_t protoVersion;
/// 同步频道消息每次大小
@property(nonatomic,assign) NSInteger syncChannelMessageLimit;
/// 协议类型
@property(nonatomic,assign) WKProto proto;
@property(nonatomic,assign) BOOL mosConvertOn; // 是否开启mos的content转换临时参数
@property(nonatomic,assign) NSInteger messageExtraSyncLimit; // 同步扩展消息每次数量限制
@property(nonatomic,assign) NSInteger channelRequestMaxLimit; // 同时发起请求频道数据的最大数量
// 是否追踪db日志
@property(nonatomic,assign) BOOL traceDBLog;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,17 @@
//
// WKPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import <Foundation/Foundation.h>
#import "WKHeader.h"
typedef NSString* (^Encode)(void);
@interface WKPacket : NSObject
@property(nonatomic,strong) WKHeader *header;
@end

View File

@ -0,0 +1,15 @@
//
// WKPacketBodyCoder.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import "WKPacket.h"
@protocol WKPacketBodyCoder <NSObject>
-(WKPacket*) decode:(NSData*) body header:(WKHeader*)header;
-(NSData*) encode:(WKPacket*)packet;
@end

View File

@ -0,0 +1,33 @@
//
// WKPakcetBodyManager.h
// WuKongIMSDK
//
// Created by tt on 2019/11/25.
//
#import <Foundation/Foundation.h>
#import "WKPacketBodyCoder.h"
#import "WKConst.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKPakcetBodyCoderManager : NSObject
/**
body解码者
@param packetType
@param bodyCoder
*/
-(void) registerBodyCoder:(WKPacketType)packetType bodyCoder:(id<WKPacketBodyCoder>)bodyCoder;
/**
body编码者
@param packetType
@return body编码者
*/
-(id<WKPacketBodyCoder>) getBodyCoder:(WKPacketType)packetType;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,17 @@
//
// WKPingPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKPingPacket : WKPacket<WKPacketBodyCoder>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,17 @@
//
// WKPongPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKPongPacket : WKPacket<WKPacketBodyCoder>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,48 @@
//
// WKRSAUtil.h
// WuKongIMSDK
//
// Created by tt on 2021/9/16.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKRSAUtil : NSObject
/**
* -------RSA -------
@param plaintext
@param pubKey
@return
*/
+ (NSString *)encrypt:(NSString *)plaintext PublicKey:(NSString *)pubKey;
/**
* -------RSA -------
@param plaintext
@param path p12或pem格式
@return
*/
+ (NSString *)encrypt:(NSString *)plaintext KeyFilePath:(NSString *)path;
/**
* -------RSA -------
@param ciphertext
@param privKey
@return
*/
+ (NSString *)decrypt:(NSString *)ciphertext PrivateKey:(NSString *)privKey;
/**
* -------RSA -------
@param ciphertext
@param path p12或pem格式(pem私钥需为pcks8格式)
@param pwd
@return
*/
+ (NSString *)decrypt:(NSString *)ciphertext KeyFilePath:(NSString *)path FilePwd:(NSString *)pwd;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
//
// WKReaction.h
// WuKongIMSDK
//
// Created by tt on 2021/9/13.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKReaction : NSObject
@property(nonatomic,strong) WKChannel *channel;
// 消息ID全局唯一
@property(nonatomic,assign) uint64_t messageId;
// 回应uid
@property(nonatomic,copy) NSString *uid;
// 回应的emoji
@property(nonatomic,copy) NSString *emoji;
@property(nonatomic,assign) uint64_t version;
// 回应时间
@property(nonatomic,copy) NSString *createdAt;
@property(nonatomic,assign) NSInteger isDeleted;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,44 @@
//
// WKReactionDB.h
// WuKongIMSDK
//
// Created by tt on 2021/9/13.
//
#import <Foundation/Foundation.h>
#import <fmdb/FMDB.h>
#import "WKReaction.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKReactionDB : NSObject
+ (WKReactionDB *)shared;
/**
*/
-(NSArray<WKReaction*>*) getReactions:(NSArray<NSNumber*>*) messageIDs;
/**
ID为key
*/
-( NSDictionary<NSString*,NSArray<WKReaction*>*> *) getReactionDictionary:(NSArray<NSNumber*>*) messageIDs;
/**
*/
-(BOOL) insertOrUpdateReactions:(NSArray<WKReaction*>*)reactions;
-(BOOL) insertOrUpdateReactions:(NSArray<WKReaction*>*)reactions db:(FMDatabase*)db;
/**
*/
-(uint64_t) maxVersion:(WKChannel*) channel;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,67 @@
//
// WKReactionManager.h
// WuKongIMSDK
//
// Created by tt on 2021/9/13.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
#import "WKReaction.h"
@class WKReactionManager;
NS_ASSUME_NONNULL_BEGIN
typedef void(^WKSyncReactionsCallback)(NSArray<WKReaction*> * __nullable reactions,NSError * __nullable error);
typedef void(^WKAddOrCancelReactionsCallback)(NSError * __nullable error);
@protocol WKReactionManagerDelegate <NSObject>
@optional
// reaction改变
-(void) reactionManagerChange:(WKReactionManager*)reactionManager reactions:(NSArray<WKReaction*>*)reactions channel:(WKChannel*)channel;
@end
@interface WKReactionManager : NSObject
+ (WKReactionManager *)shared;
/**
,reactionName的回应则取消回应
@param reactionName emoji或本地emoji图片的名称
@param messageID ID
@param complete
*/
-(void) addOrCancelReaction:(NSString*)reactionName messageID:(uint64_t)messageID complete:(void(^_Nullable)(NSError * _Nullable error))complete;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKReactionManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKReactionManagerDelegate>) delegate;
-(void) sync:(WKChannel*)channel;
// 同步点赞数据提供者
@property(nonatomic,copy) void(^syncReactionsProvider)(WKChannel *channel,uint64_t maxVersion,WKSyncReactionsCallback callback);
// 添加或取消点赞数据提供者
@property(nonatomic,copy) void(^addOrCancelReactionProvider)(WKChannel*channel,uint64_t messageID, NSString *reactionName,WKAddOrCancelReactionsCallback callback);
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,37 @@
//
// WKReceiptManager.h
// WuKongIMSDK
//
// Created by tt on 2021/4/9.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
// 消息已读
typedef void(^WKMessageReadedCallback)(NSError * __nullable error);
typedef void(^WKMessageReadedProvider)(WKChannel *channel,NSArray<WKMessage*>*messages,WKMessageReadedCallback callback);
@interface WKReceiptManager : NSObject
+ (WKReceiptManager *)shared;
/**
*/
-(void) addReceiptMessages:(WKChannel*)channel messages:(NSArray<WKMessage*>*)messages;
/**
flush到服务器
*/
//-(void) flush:(WKChannel*)channel complete:(void(^)(NSError *error))complete;
// 消息已读提供者
@property(nonatomic,copy) WKMessageReadedProvider messageReadedProvider;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,38 @@
//
// WKRecvPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
#import "WKSetting.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKRecvPacket : WKPacket<WKPacketBodyCoder>
// 消息设置
@property(nonatomic,strong) WKSetting *setting;
// 消息唯一ID
@property(nonatomic,assign) uint64_t messageId;
// 消息序列号 (用户唯一,有序递增)
@property(nonatomic,assign) uint32_t messageSeq;
// 客户端消息唯一编号(用于消息去重)
@property(nonatomic,copy) NSString *clientMsgNo;
// 服务器时间
@property(nonatomic,assign) uint32_t timestamp;
// 发送者UID
@property(nonatomic,copy) NSString *fromUid;
//频道ID如果是个人频道ChannelId为个人的UID
@property(nonatomic,copy) NSString *channelId;
//频道类型1.个人 2.群组)
@property(nonatomic,assign) uint8_t channelType;
// 话题
@property(nonatomic,copy) NSString *topic;
// 负荷数据
@property(nonatomic,strong) NSData *payload;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,20 @@
//
// WKRecvackPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/30.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKRecvackPacket : WKPacket<WKPacketBodyCoder>
@property(nonatomic,assign) uint64_t messageId;
@property(nonatomic,assign) uint32_t messageSeq;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,54 @@
//
// WKReminder.h
// WuKongIMSDK
//
// Created by tt on 2022/4/19.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKReminderTypeMentionMe = 1, // 有人@我
} WKReminderType;
typedef enum : NSUInteger {
WKReminderUploadStatusSuccess, // 成功
WKReminderUploadStatusWait, // 等待上传
WKReminderUploadStatusError, // 上传错误
} WKReminderUploadStatus; // 提醒项上传状态
@interface WKReminder : NSObject<NSCopying>
@property(nonatomic,assign) int64_t reminderID;
@property(nonatomic,assign) uint64_t messageId;
@property(nonatomic,assign) uint32_t messageSeq; // 消息序列号(用户唯一,有序)
@property(nonatomic,strong) WKChannel *channel; // 频道
@property(nonatomic,assign) WKReminderType type; // 提醒类型
@property(nonatomic,copy) NSString *publisher; // 发布者uid
@property(nonatomic,copy) NSString *text; // 提醒文本
@property(nonatomic,strong) NSDictionary *data; // 提醒包含的数据
@property(nonatomic,assign) BOOL isLocate; // 是否需要进行消息定位
@property(nonatomic,assign) int64_t version;
@property(nonatomic,assign) BOOL done; // 用户是否完成提醒
@property(nonatomic,assign) WKReminderUploadStatus uploadStatus; // 上传状态 只对本地生效
/**
@return <#return value description#>
*/
-(NSDictionary*) toDictionary;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,49 @@
//
// WKReminderDB.h
// WuKongIMSDK
//
// Created by tt on 2022/4/19.
//
#import <Foundation/Foundation.h>
#import "WKReminder.h"
#import "WKChannel.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKReminderDB : NSObject
+ (WKReminderDB *)shared;
-(void) addOrUpdates:(NSArray<WKReminder*>*)reminders;
/**
done的提醒项
*/
-(NSDictionary<WKChannel*,NSArray<WKReminder*>*>*) getWaitDoneReminders:(NSArray<WKChannel*>*) channels;
-(NSArray<WKReminder*>*) getWaitDoneReminder:(WKChannel*) channel;
-(NSArray<WKReminder*>*) getWaitDoneReminders:(WKChannel*)channel type:(WKReminderType)type;
// 获取所有等待完成的提醒
-(NSDictionary<WKChannel*,NSArray<WKReminder*>*>*) getAllWaitDoneReminders;
-(int64_t) getMaxVersion;
// 将对应id的提醒更新为done状态
-(void) updateDone:(NSArray<NSNumber*>*)ids;
// 更新过期的done=1的数据的上传状态为失败
-(void) updateExpireDoneUploadStatusFail:(NSInteger)expireTime;
-(void) updateUploadStatus:(WKReminderUploadStatus)status reminderID:(NSNumber*)reminderID;
-(NSArray<WKReminder*>*) getWaitUploads;
// 获取提醒项列表
-(NSArray<WKReminder*>*) getReminders:(NSArray<NSNumber*>*)ids;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,61 @@
//
// WKReminderManager.h
// WuKongIMSDK
//
// Created by tt on 2022/4/19.
//
#import <Foundation/Foundation.h>
#import "WKReminder.h"
@class WKReminderManager;
NS_ASSUME_NONNULL_BEGIN
// 消息提醒提供
typedef void(^WKReminderCallback)(NSArray<WKReminder*> * __nullable reminders,NSError * __nullable error);
typedef void(^WKReminderProvider)(WKReminderCallback callback);
// 消息提醒done提供
typedef void(^WKReminderDoneCallback)(NSError * __nullable error);
typedef void(^WKReminderDoneProvider)(NSArray<NSNumber*> *ids,WKReminderDoneCallback callback);
@protocol WKReminderManagerDelegate <NSObject>
@optional
// 某个频道的reminders发生变化
-(void) reminderManager:(WKReminderManager*)manager didChange:(WKChannel*)channel reminders:(NSArray<WKReminder*>*) reminders;
@end
@interface WKReminderManager : NSObject
+ (WKReminderManager *)shared;
-(void) sync;
-(void) done:(NSArray<NSNumber*>*)ids;
/**
@param delegate <#delegate description#>
*/
-(void) addDelegate:(id<WKReminderManagerDelegate>) delegate;
/**
@param delegate <#delegate description#>
*/
-(void)removeDelegate:(id<WKReminderManagerDelegate>) delegate;
@property(nonatomic,copy) WKReminderProvider reminderProvider; // 消息提醒项内容同步提供者
@property(nonatomic,copy) WKReminderDoneProvider reminderDoneProvider; // 消息提醒项完成提供者
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,66 @@
//
// WKRetryManager.h
// WuKongIMBase
//
// Created by tt on 2019/12/29.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
#import "WKReminder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKRetryItem : NSObject
// 消息
@property(nonatomic,strong) WKMessage *message;
@property(nonatomic,strong) WKMessageExtra *messageExtra;
@property(nonatomic,strong) WKReminder *reminder;
// 重试次数
@property(nonatomic,assign) long retryCount;
// 下次重试时间
@property(nonatomic,assign) long nextRetryTime;
@property(nonatomic,assign) long nextRetryTime2;
@end
@interface WKRetryManager : NSObject
+ (WKRetryManager *)shared;
/**
*/
-(void) start;
/**
*/
-(void) stop;
/**
@param message
*/
-(void) add:(WKMessage*)message;
-(void) addMessageExtra:(WKMessageExtra*)messageExtra;
/**
@param key key
*/
-(void) removeRetryItem:(NSString*) key;
-(void) removeMessageExtraRetryItem:(NSString*) key;
-(void) addReminder:(WKReminder*)reminder;
-(void) removeReminderRetryItem:(NSString*)key;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,43 @@
//
// WKRobot.h
// WuKongIMSDK
//
// Created by tt on 2021/10/19.
//
#import <Foundation/Foundation.h>
typedef enum : NSUInteger {
WKRobotStatusDisable,
WKRobotStatusEnable,
} WKRobotStatus;
@class WKRobotMenus;
NS_ASSUME_NONNULL_BEGIN
@interface WKRobot : NSObject
@property (nonatomic, copy) NSString *robotID;
@property (nonatomic, copy) NSString *username; // 机器人username
@property (nonatomic, assign) long version;
@property(nonatomic,assign) WKRobotStatus status;
@property(nonatomic,assign) BOOL inlineOn; // 是否支持行内搜索
@property(nonatomic,copy) NSString *placeholder; // 如果支持行内搜索 则占位字符内容
@property (nonatomic, strong) NSArray<WKRobotMenus*> *menus;
@end
@interface WKRobotMenus : NSObject
@property (nonatomic, copy) NSString *robotID;
@property (nonatomic, copy) NSString *cmd;
@property (nonatomic, copy) NSString *remark;
@property (nonatomic, copy) NSString *type;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// WKRobotDB.h
// WuKongIMSDK
//
// Created by tt on 2021/10/19.
//
#import <Foundation/Foundation.h>
#import "WKRobot.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKRobotDB : NSObject
+ (WKRobotDB *)shared;
/// 查询robot
-(NSArray<WKRobot*>*) queryRobots:(NSArray<NSString*>*)robotIDs;
-(void) addOrUpdateRobots:(NSArray<WKRobot*>*)robots;
-(WKRobot*) queryRobotWithUsername:(NSString*)username;
-(NSArray<WKRobot*>*) queryRobotsWithUsernames:(NSArray<NSString*>*)usernames;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,36 @@
//
// WKRobotManager.h
// WuKongIMSDK
//
// Created by tt on 2021/10/19.
//
#import <Foundation/Foundation.h>
#import "WKRobot.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^WKSyncRobotCallback)(NSArray<WKRobot*>* __nullable robots,NSError * __nullable error);
typedef void(^WKSyncRobotProvider)(NSArray<NSDictionary*> *robotVersionDicts,WKSyncRobotCallback callback);
@interface WKRobotManager : NSObject
+ (WKRobotManager *)shared;
/// 机器人数据提供者
@property(nonatomic,copy) WKSyncRobotProvider syncRobotProvider;
// 通过机器人id同步机器人
-(void) sync:(NSArray<NSString*>*)robotIDs complete:(void(^)(BOOL hasData,NSError *error))complete;
// 通过username同步机器人
-(void) syncWithUsernames:(NSArray<NSString*>*)usernames complete:(void(^)(BOOL hasData,NSError *error))complete;
/**
username
@param username
*/
-(WKRobot*) getRobotWithUsername:(NSString*)username;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,165 @@
//
// WKSDK.h
// WuKongIMSDK
//
// Created by tt on 2019/11/23.
//
#import "WuKongIMSDKHeader.h"
NS_ASSUME_NONNULL_BEGIN
// 悟空IM SDK
@interface WKSDK : NSObject
+ (WKSDK *)shared;
@property(nonatomic,strong) WKOptions* options;
/**
*/
@property(nonatomic,copy) NSString *connectURL;
/**
*/
@property(nonatomic,strong) WKConnectionManager *connectionManager;
/**
*/
@property(nonatomic,strong) WKChatManager *chatManager;
/**
*/
@property(nonatomic,strong) WKChannelManager *channelManager;
/**
*/
@property(nonatomic,strong) WKChannelInfoUpdate channelInfoUpdate;
/**
*/
@property(nonatomic,strong) WKMediaManager *mediaManager;
/**
*/
@property(nonatomic,strong) WKCoder *coder;
/**
body的编码解码者管理
*/
@property(nonatomic,strong) WKPakcetBodyCoderManager *bodyCoderManager;
/**
*/
@property(nonatomic,strong) WKConversationManager *conversationManager;
/// cmd管理者
@property(nonatomic,strong) WKCMDManager *cmdManager;
// 消息已读回执管理者
@property(nonatomic,strong) WKReceiptManager *receiptManager;
// 消息回应管理
// 负责点赞数据的维护
@property(nonatomic,strong) WKReactionManager *reactionManager;
// 机器人管理者
@property(nonatomic,strong) WKRobotManager *robotManager;
// 提醒管理者
// 负责最近会话的提醒项,比如 有人@我,入群申请等等 还可以自定义一些提醒,比如类似微信的 [红包] [转账] 列表都会有提醒
@property(nonatomic,strong) WKReminderManager *reminderManager;
@property(nonatomic,strong) WKFlameManager *flameManager; // 阅后即焚管理者
// sdk版本号每次升级记得修改此处
@property(nonatomic,copy,readonly) NSString *sdkVersion;
/**
debug模式
@return <#return value description#>
*/
-(BOOL) isDebug;
/// 注册消息正文
/// @param cls 正文的class 需要继承WKMessageContent
-(void) registerMessageContent:(Class)cls;
/// 注册消息正文(指定正文类型)
/// @param cls 正文的class 需要继承WKMessageContent
/// @param contentType 正文类型
-(void) registerMessageContent:(Class)cls contentType:(NSInteger)contentType;
/**
@param contentType <#contentType description#>
@return <#return value description#>
*/
-(Class) getMessageContent:(NSInteger)contentType;
/**
contentType类型为 [1000,2000]
@param contentType
@return <#return value description#>
*/
-(BOOL) isSystemMessage:(NSInteger)contentType;
// 离线消息拉取(普通模式)
@property(nonatomic,copy,readonly) WKOfflineMessagePull offlineMessagePull;
@property(nonatomic,copy,readonly) WKOfflineMessageAck offlineMessageAck;
// 离线会话拉取(万人群模式)
//@property(nonatomic,copy,readonly) WKOfflineMessagePull offlineMessagePull;
/**
线
@param offlineMessageCallback
@param offlineMessageAckCallback ack回调
*/
-(void) setOfflineMessageProvider:(WKOfflineMessagePull) offlineMessageCallback offlineMessagesAck:(WKOfflineMessageAck) offlineMessageAckCallback;
/**
@param message <#message description#>
@return <#return value description#>
*/
-(WKMessageFileUploadTask*) getMessageFileUploadTask:(WKMessage*)message;
/// 获取消息下载任务
/// @param message <#message description#>
-(WKMessageFileDownloadTask*) getMessageDownloadTask:(WKMessage*)message;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,48 @@
//
// WKSecurityManager.h
// WuKongIMSDK
//
// Created by tt on 2021/2/24.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKSecurityManager : NSObject
+ (WKSecurityManager *)shared;
@property(nonatomic,copy) NSString *sharedKey; // 共享key
/**
DH密钥对
*/
-(void) generateDHPair;
/**
DH的公钥
*/
-(NSString*) getDHPubKey;
/**
*/
-(void) generateAesKey:(NSString*)pubKey salt:(NSString*)salt;
/**
*/
-(NSString*) encryption:(NSString*)data;
/**
*/
-(NSString*) decryption:(NSString*)data;
- (NSString *)md5:(NSString *)input;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,37 @@
//
// WKSendPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
#import "WKSetting.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKSendPacket : WKPacket<WKPacketBodyCoder>
@property(nonatomic,strong) WKSetting *setting;
// 客户端提供的序列号,在客户端内唯一
@property(nonatomic,assign) uint32_t clientSeq;
/// 客户端消息唯一编号
@property(nonatomic,copy) NSString *clientMsgNo;
//频道ID如果是个人频道ChannelId为个人的UID
@property(nonatomic,copy) NSString *channelId;
//频道类型1.个人 2.群组)
@property(nonatomic,assign) uint8_t channelType;
// 话题
@property(nonatomic,copy) NSString *topic;
// 负荷数据
@property(nonatomic,strong) NSData *payload;
-(NSString*) veritifyString;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
//
// WKSendackPacket.h
// WuKongIMSDK
//
// Created by tt on 2019/11/27.
//
#import <Foundation/Foundation.h>
#import "WKPacket.h"
#import "WKPacketBodyCoder.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKSendackPacket : WKPacket<WKPacketBodyCoder>
// 客户端序列号 (客户端提供,服务端原样返回)
@property(nonatomic,assign) uint32_t clientSeq;
// 消息ID全局唯一
@property(nonatomic,assign) uint64_t messageId;
// 消息序列号(用户唯一,有序)
@property(nonatomic,assign) uint32_t messageSeq;
// 原因代码
@property(nonatomic,assign) uint8_t reasonCode;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,29 @@
//
// WKSetting.h
// WuKongIMSDK
//
// Created by tt on 2021/4/9.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKSetting : NSObject
@property (nonatomic,assign) BOOL receiptEnabled; // 消息是否需要发送已读回执
//@property(nonatomic,assign) BOOL signal; // 是否signal加密
@property(nonatomic,assign) BOOL topic; // 是否存在话题
-(uint8_t) toUint8;
+(WKSetting*) fromUint8:(uint8_t)v;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,16 @@
//
// WKSignalErrorContent.h
// WuKongIMSDK
//
// Created by tt on 2021/9/9.
//
#import <WuKongIMSDK/WuKongIMSDK.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKSignalErrorContent : WKMessageContent
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,21 @@
//
// WKSyncChannelMessageModel.h
// WuKongIMSDK
//
// Created by tt on 2020/10/5.
//
#import <Foundation/Foundation.h>
#import "WKMessage.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKSyncChannelMessageModel : NSObject
@property(nonatomic,assign) uint32_t startMessageSeq; // 开始消息序列号
@property(nonatomic,assign) uint32_t endMessageSeq; // 结束消息序列号
@property(nonatomic,assign) BOOL more; // 是否还有更多数据
@property(nonatomic,strong) NSArray<WKMessage*> *messages; // 消息集合
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,70 @@
//
// WKOfflineConversation.h
// WuKongIMSDK
//
// Created by tt on 2020/9/30.
//
#import <Foundation/Foundation.h>
#import "WKChannel.h"
#import "WKMessage.h"
#import "WKConversation.h"
#import "WKCMDDB.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKSyncConversationModel : NSObject
@property(nonatomic,strong) WKChannel *channel; // 频道
@property(nonatomic,strong) WKChannel *parentChannel; // 频道
@property(nonatomic,assign) NSInteger unread; // 消息未读数
@property(nonatomic,assign) BOOL mute;
@property(nonatomic,assign) BOOL stick;
@property(nonatomic,assign) NSTimeInterval timestamp; // 最后一次会话时间
@property(nonatomic,assign) uint32_t lastMsgSeq; // 最后一次会话的消息序列号
@property(nonatomic,copy) NSString *lastMsgClientNo; // 最后一次会话的消息客户端编号
@property(nonatomic,assign) long long version; // 数据版本
@property(nonatomic,strong) NSArray<WKMessage*> *recents; // 会话的最新消息集合
@property(nonatomic,strong) WKConversationExtra *remoteExtra;
@property(nonatomic,strong,readonly) WKConversation *conversation;
@end
@interface WKCMDModel : NSObject
@property(nonatomic,copy) NSString *no; // cmd唯一编号
@property(nonatomic,copy) NSString *cmd;
// 消息时间(服务器时间,单位秒)
@property(nonatomic,assign) NSInteger timestamp;
// cmd 参数
@property(nonatomic,strong) NSDictionary *param;
+(WKCMDModel*) message:(WKMessage*)message;
+(WKCMDModel*) cmdMessage:(WKCMDMessage*)cmdMessage;
@end
@interface WKSyncConversationWrapModel : NSObject
@property(nonatomic,strong) NSArray<WKSyncConversationModel*> *conversations;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,19 @@
//
// WKSystemContent.h
// WuKongIMSDK
//
// Created by tt on 2020/1/4.
//
#import <Foundation/Foundation.h>
#import "WKMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKSystemContent : WKMessageContent
@property(nonatomic,strong) NSDictionary *content;
@property(nonatomic,copy) NSString *displayContent;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,61 @@
//
// WKTaskManager.h
// WuKongIMSDK
//
// Created by tt on 2020/1/15.
//
#import <Foundation/Foundation.h>
#import "WKTaskProto.h"
NS_ASSUME_NONNULL_BEGIN
@protocol WKTaskManagerDelegate <NSObject>
@optional
/**
@param task <#task description#>
*/
-(void) taskComplete:(id<WKTaskProto>)task;
/**
@param task <#task description#>
*/
-(void) taskProgress:(id<WKTaskProto>)task;
@end
@interface WKTaskManager : NSObject
@property(nonatomic,weak) id<WKTaskManagerDelegate> delegate;
/**
@param task <#task description#>
*/
-(void) add:(id<WKTaskProto>)task;
/**
@param taskId <#taskId description#>
*/
-(id<WKTaskProto> __nullable) get:(NSString *)taskId;
/**
@param task <#task description#>
*/
-(void) remove:(id<WKTaskProto>)task;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,33 @@
//
// WKTaskOperator.h
// WuKongIMSDK
//
// Created by tt on 2021/4/22.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKTaskOperator : NSObject
+(WKTaskOperator*) cancel:(void(^)(void))cancel suspend:(void(^)(void))suspend resume:(void(^)(void))resume;
/**
*/
@property (nonatomic, copy) void(^cancel)(void);
/**
*/
@property (nonatomic, copy) void(^suspend)(void);
/**
*/
@property (nonatomic, copy) void(^resume)(void);
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,84 @@
//
// WKTask.h
// WuKongIMSDK
//
// Created by tt on 2020/1/15.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
WKTaskStatusWait, // 任务等待执行
WKTaskStatusSuccess, // 任务执行成功
WKTaskStatusProgressing, // 任务处理中
WKTaskStatusSuspend, // 任务挂起
WKTaskStatusError, // 任务执行错误
WKTaskStatusCancel, // 任务执行错误
} WKTaskStatus;
typedef void(^WKTaskListener)(void);
@protocol WKTaskProto <NSObject>
/**
*/
@property(nonatomic,copy,readonly) NSArray<WKTaskListener> *listeners;
/**
ID
*/
@property(nonatomic,copy) NSString *taskId;
/**
*/
@property(nonatomic,assign) WKTaskStatus status;
/**
@param listener
@param target
*/
- (void)addListener:(nonnull WKTaskListener)listener target:(id) target;
/**
@param target <#target description#>
*/
-(void) removeListener:(id) target;
/**
*/
-(void) resume;
/**
*/
-(void) suspend;
/**
*/
-(void) cancel;
/**
*/
-(void) update;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,22 @@
//
// WKText.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
#import <Foundation/Foundation.h>
#import "WKMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKTextContent : WKMessageContent
- (instancetype)initWithContent:(NSString*)content;
@property(nonatomic,copy) NSString *content;
@property(nonatomic,copy,nullable) NSString *format; // 内容格式 默认为普通文本 html,markdown
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,19 @@
//
// WKUUIDUtil.h
// WuKongIMSDK
//
// Created by tt on 2020/5/28.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKUUIDUtil : NSObject
+ (NSString*)getUUID;
+(NSString*) getClientMsgNo:(NSString*)custId toCustId:(NSString*)toCustId chatId:(NSString*)chatId;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,17 @@
//
// WKUnknownContent.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
#import <Foundation/Foundation.h>
#import "WKMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKUnknownContent : WKMessageContent
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,39 @@
//
// WKUser.h
// WuKongIMSDK
//
// Created by tt on 2019/11/29.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKUserInfo : NSObject
-(instancetype) initWithUid:(NSString*)uid name:(NSString*__nullable)name avatar:(NSString* __nullable)avatar;
-(instancetype) initWithUid:(NSString*)uid name:(NSString*)name;
/*!
ID
*/
@property (nonatomic, copy) NSString *uid;
/*!
*/
@property (nonatomic, copy) NSString *name;
/*!
URL
*/
@property (nonatomic, copy) NSString *avatar;
/**
*/
@property (nonatomic, copy) NSString *extra;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,36 @@
//
// WKVoiceContent.h
// WuKongIMSDK
//
// Created by tt on 2020/1/16.
//
#import <Foundation/Foundation.h>
#import "WKMediaMessageContent.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKVoiceContent : WKMediaMessageContent
/**
@param voiceData
@param second
@param waveform
@return <#return value description#>
*/
+ (instancetype)initWithData:(NSData *)voiceData second:(int)second waveform:(NSData*)waveform;
// 音频数据
@property(nonatomic,strong) NSData *voiceData;
// 音频长度(单位秒)
@property(nonatomic,assign) NSInteger second;
// 音频波浪数据 (可选参数)
@property(nonatomic,strong) NSData *waveform;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,110 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "WKConnackPacket.h"
#import "WKConnectPacket.h"
#import "WKDisconnectPacket.h"
#import "WKPacket.h"
#import "WKPingPacket.h"
#import "WKPongPacket.h"
#import "WKRecvackPacket.h"
#import "WKRecvPacket.h"
#import "WKSendackPacket.h"
#import "WKSendPacket.h"
#import "WKCoder.h"
#import "WKData.h"
#import "WKHeader.h"
#import "WKPacketBodyCoder.h"
#import "WKPakcetBodyCoderManager.h"
#import "WKSetting.h"
#import "WKChannelInfoDB.h"
#import "WKChannelMemberDB.h"
#import "WKCMDDB.h"
#import "WKConversationDB.h"
#import "WKConversationExtraDB.h"
#import "WKConversationUtil.h"
#import "WKDB.h"
#import "WKDBMigrationManager.h"
#import "WKFMDatabaseQueue.h"
#import "WKMessageDB.h"
#import "WKMessageExtraDB.h"
#import "WKReactionDB.h"
#import "WKReminderDB.h"
#import "WKRobotDB.h"
#import "WKBaseTask.h"
#import "WKMessageFileDownloadTask.h"
#import "WKMessageFileUploadTask.h"
#import "WKTaskProto.h"
#import "WKChannelManager.h"
#import "WKChannelRequestQueue.h"
#import "WKChatDataProvider.h"
#import "WKChatManager.h"
#import "WKChatManagerInner.h"
#import "WKCMDManager.h"
#import "WKConnectionManager.h"
#import "WKConversationManager.h"
#import "WKConversationManagerInner.h"
#import "WKFlameManager.h"
#import "WKMediaManager.h"
#import "WKMOSContentConvertManager.h"
#import "WKReactionManager.h"
#import "WKReceiptManager.h"
#import "WKReminderManager.h"
#import "WKRetryManager.h"
#import "WKRobotManager.h"
#import "WKSecurityManager.h"
#import "WKTaskManager.h"
#import "WKCMDContent.h"
#import "WKImageContent.h"
#import "WKMediaMessageContent.h"
#import "WKMessageContent.h"
#import "WKMultiMediaMessageContent.h"
#import "WKSignalErrorContent.h"
#import "WKSystemContent.h"
#import "WKTextContent.h"
#import "WKUnknownContent.h"
#import "WKVoiceContent.h"
#import "WKChannel.h"
#import "WKChannelInfo.h"
#import "WKChannelInfoSearchResult.h"
#import "WKChannelMessageSearchResult.h"
#import "WKConnectInfo.h"
#import "WKConversation.h"
#import "WKConversationExtra.h"
#import "WKConversationLastMessageAndUnreadCount.h"
#import "WKMediaProto.h"
#import "WKMessage.h"
#import "WKMessageExtra.h"
#import "WKMessageStatusModel.h"
#import "WKReaction.h"
#import "WKReminder.h"
#import "WKRobot.h"
#import "WKSyncChannelMessageModel.h"
#import "WKSyncConversationModel.h"
#import "WKTaskOperator.h"
#import "WKUserInfo.h"
#import "WKAESUtil.h"
#import "WKFileUtil.h"
#import "WKMediaUtil.h"
#import "WKMemoryCache.h"
#import "WKNOGeneraterUtil.h"
#import "WKRSAUtil.h"
#import "WKUUIDUtil.h"
#import "WKConst.h"
#import "WKOptions.h"
#import "WKSDK.h"
#import "WuKongIMSDK.h"
#import "WuKongIMSDKHeader.h"
FOUNDATION_EXPORT double WuKongIMSDKVersionNumber;
FOUNDATION_EXPORT const unsigned char WuKongIMSDKVersionString[];

View File

@ -0,0 +1,43 @@
//
// WuKongIMSDK.h
// Pods
//
// Created by tt on 2019/11/23.
//
#import "WKSDK.h"
#import "WKConnackPacket.h"
#import "WKSendPacket.h"
#import "WKDB.h"
#import "WKChannel.h"
#import "WKChannelManager.h"
#import "WKMessageDB.h"
#import "WKChannelInfoDB.h"
#import "WKVoiceContent.h"
#import "WKMessageContent.h"
#import "WKTextContent.h"
#import "WKUnknownContent.h"
#import "WKSystemContent.h"
#import "WKImageContent.h"
#import "WKMultiMediaMessageContent.h"
#import "WKMessageFileUploadTask.h"
#import "WKFileUtil.h"
#import "WKConversation.h"
#import "WKCMDContent.h"
#import "WKMediaMessageContent.h"
#import "WKTaskProto.h"
#import "WKMessageFileDownloadTask.h"
#import "WKMemoryCache.h"
#import "WKSecurityManager.h"
#import "WKAESUtil.h"
#import "WKRobotDB.h"
#import "WKMessageExtra.h"
#import "WKMessageExtraDB.h"
#import "WKReminderDB.h"

View File

@ -0,0 +1,75 @@
//
// WuKongIMSDKHeader.h
// Pods
//
// Created by tt on 2022/12/13.
//
#import <Foundation/Foundation.h>
#import "WKOptions.h"
#import "WKConnectionManager.h"
#import "WKCoder.h"
#import "WKPakcetBodyCoderManager.h"
#import "WKChatManager.h"
#import "WKMessageContent.h"
#import "WKConversationManager.h"
#import "WKChannelManager.h"
#import "WKMediaManager.h"
#import "WKMessageFileUploadTask.h"
#import "WKMessageFileDownloadTask.h"
#import "WKTaskManager.h"
#import "WKCMDManager.h"
#import "WKReceiptManager.h"
#import "WKTaskOperator.h"
#import "WKReactionManager.h"
#import "WKRobotManager.h"
#import "WKReminderManager.h"
#import "WKFlameManager.h"
#import "WKConst.h"
NS_ASSUME_NONNULL_BEGIN
/**
@param error
*/
typedef void (^WKChannelInfoCallback)(NSError * _Nullable error,bool notifyBefore);
/**
线
@param messages 线
@param more
@param error
*/
typedef void(^WKOfflineMessageCallback)(NSArray<WKMessage*>* __nullable messages,bool more,NSError * __nullable error);
/**
线ack回调
@param messageSeq
*/
typedef void(^WKOfflineMessageAck)(uint32_t messageSeq,void(^complete)(NSError *error));
/**
*/
typedef WKTaskOperator* _Nullable (^WKChannelInfoUpdate)(WKChannel *channel,WKChannelInfoCallback callback);
/**
线
@param limit <#limit description#>
@param messageSeq <#messageSeq description#>
@param callback <#callback description#>
*/
typedef void (^WKOfflineMessagePull)(int limit,uint32_t messageSeq,WKOfflineMessageCallback callback);
NS_ASSUME_NONNULL_END

Some files were not shown because too many files have changed in this diff Show More